Merge pull request #4875 from tiennou/fix/openssl-errors Some OpenSSL issues
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
diff --git a/src/streams/openssl.c b/src/streams/openssl.c
index 7fd810a..a68f9a9 100644
--- a/src/streams/openssl.c
+++ b/src/streams/openssl.c
@@ -373,10 +373,10 @@ static int ssl_set_error(SSL *ssl, int error)
switch (err) {
case SSL_ERROR_WANT_CONNECT:
case SSL_ERROR_WANT_ACCEPT:
- giterr_set(GITERR_NET, "SSL error: connection failure");
+ giterr_set(GITERR_SSL, "SSL error: connection failure");
break;
case SSL_ERROR_WANT_X509_LOOKUP:
- giterr_set(GITERR_NET, "SSL error: x509 error");
+ giterr_set(GITERR_SSL, "SSL error: x509 error");
break;
case SSL_ERROR_SYSCALL:
e = ERR_get_error();
@@ -389,7 +389,7 @@ static int ssl_set_error(SSL *ssl, int error)
giterr_set(GITERR_OS, "SSL error: syscall failure");
break;
}
- giterr_set(GITERR_NET, "SSL error: received early EOF");
+ giterr_set(GITERR_SSL, "SSL error: received early EOF");
return GIT_EEOF;
break;
case SSL_ERROR_SSL:
@@ -397,13 +397,13 @@ static int ssl_set_error(SSL *ssl, int error)
char errmsg[256];
e = ERR_get_error();
ERR_error_string_n(e, errmsg, sizeof(errmsg));
- giterr_set(GITERR_NET, "SSL error: %s", errmsg);
+ giterr_set(GITERR_SSL, "SSL error: %s", errmsg);
break;
}
case SSL_ERROR_NONE:
case SSL_ERROR_ZERO_RETURN:
default:
- giterr_set(GITERR_NET, "SSL error: unknown error");
+ giterr_set(GITERR_SSL, "SSL error: unknown error");
break;
}
return -1;
@@ -586,8 +586,6 @@ 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);
@@ -602,6 +600,8 @@ int openssl_connect(git_stream *stream)
if ((ret = SSL_connect(st->ssl)) <= 0)
return ssl_set_error(st->ssl, ret);
+ st->connected = true;
+
return verify_server_cert(st->ssl, st->host);
}