diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-02 14:06:30 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-17 18:57:27 +0100 |
commit | 6e7f733c695281f71e56d5203783454068a61f69 (patch) | |
tree | aba57e443b327285c0aee37816b91ad167138d8d | |
parent | 4c6a47ab4551f5f74995ed02c08acc9eb346b4d9 (diff) | |
download | libgit2-6e7f733c695281f71e56d5203783454068a61f69.tar.gz |
WIP more stransport
-rw-r--r-- | src/stransport_stream.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/stransport_stream.c b/src/stransport_stream.c index 6570d0b1d..3a643acaa 100644 --- a/src/stransport_stream.c +++ b/src/stransport_stream.c @@ -14,8 +14,14 @@ int stransport_error(OSStatus ret) { - giterr_set(GITERR_NET, "foo"); - return -1; + switch (ret) { + case noErr: + giterr_clear(); + return 0; + default: + giterr_set(GITERR_NET, "foo"); + return -1; + } } typedef struct { @@ -39,6 +45,21 @@ int stransport_connect(git_stream *stream) return 0; } +int stransport_certificate(git_cert **out, git_stream *stream) +{ + stransport_stream *st = (stransport_stream *) stream; + SecTrustRef trust; + OSStatus ret; + + if ((ret = SSLCopyPeerTrust(st->ctx, &trust)) != noErr) + return stransport_error(ret); + + CFRelease(trust); + + giterr_set(GITERR_SSL, "not implemented yet"); + return -1; +} + static OSStatus write_cb(SSLConnectionRef conn, const void *data, size_t *len) { git_stream *io = (git_stream *) conn; @@ -96,6 +117,17 @@ ssize_t stransport_read(git_stream *stream, void *data, size_t len) return processed; } +int stransport_close(git_stream *stream) +{ + stransport_stream *st = (stransport_stream *) stream; + OSStatus ret; + + if ((ret = SSLClose(st->ctx)) != noErr) + return stransport_error(ret); + + return git_stream_close(st->io); +} + void stransport_free(git_stream *stream) { stransport_stream *st = (stransport_stream *) stream; @@ -129,6 +161,13 @@ int git_stransport_stream_new(git_stream **out, const char *host, const char *po return stransport_error(ret); } + st->parent.encrypted = 1; + st->parent.connect = stransport_connect; + st->parent.certificate = stransport_certificate; + st->parent.read = stransport_read; + st->parent.write = stransport_write; + st->parent.close = stransport_close; + st->parent.free = stransport_free; *out = (git_stream *) st; return 0; |