diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-09-30 09:41:25 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-11-04 17:06:54 -0800 |
commit | 08a2a939c2a6073bed5292ab23f48eabf1244166 (patch) | |
tree | c4da11e503935be38c0b2109b2e3eb985253a674 | |
parent | 7dd51284a03efdf2738c5eb74248d4c93d1d132a (diff) | |
download | libgit2-08a2a939c2a6073bed5292ab23f48eabf1244166.tar.gz |
openssl: don't try to teardown an unconnected SSL context
SSL_shutdown() does not like it when we pass an unitialized ssl context
to it. This means that when we fail to connect to a host, we hide the
error message saying so with OpenSSL's indecipherable error message.
-rw-r--r-- | src/openssl_stream.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/openssl_stream.c b/src/openssl_stream.c index 4df7c6b7c..16ee78341 100644 --- a/src/openssl_stream.c +++ b/src/openssl_stream.c @@ -302,6 +302,7 @@ cert_fail_name: typedef struct { git_stream parent; git_stream *io; + bool connected; char *host; SSL *ssl; git_cert_x509 cert_info; @@ -318,6 +319,8 @@ int openssl_connect(git_stream *stream) if ((ret = git_stream_connect(st->io)) < 0) return ret; + st->connected = true; + bio = BIO_new(&git_stream_bio_method); GITERR_CHECK_ALLOC(bio); bio->ptr = st->io; @@ -405,9 +408,11 @@ int openssl_close(git_stream *stream) openssl_stream *st = (openssl_stream *) stream; int ret; - if ((ret = ssl_teardown(st->ssl)) < 0) + if (st->connected && (ret = ssl_teardown(st->ssl)) < 0) return -1; + st->connected = false; + return git_stream_close(st->io); } |