Commit 51d3f6f5 by Carlos Martín Nieto

netops: provide more specific error for cert failure

Specify what we do not like about the certificate. In this case, we do
not like the name.
parent 1f0d4f3d
...@@ -321,7 +321,7 @@ static int verify_server_cert(gitno_ssl *ssl, const char *host) ...@@ -321,7 +321,7 @@ static int verify_server_cert(gitno_ssl *ssl, const char *host)
GENERAL_NAMES_free(alts); GENERAL_NAMES_free(alts);
if (matched == 0) if (matched == 0)
goto cert_fail; goto cert_fail_name;
if (matched == 1) if (matched == 1)
return 0; return 0;
...@@ -358,11 +358,11 @@ static int verify_server_cert(gitno_ssl *ssl, const char *host) ...@@ -358,11 +358,11 @@ static int verify_server_cert(gitno_ssl *ssl, const char *host)
int size = ASN1_STRING_to_UTF8(&peer_cn, str); int size = ASN1_STRING_to_UTF8(&peer_cn, str);
GITERR_CHECK_ALLOC(peer_cn); GITERR_CHECK_ALLOC(peer_cn);
if (memchr(peer_cn, '\0', size)) if (memchr(peer_cn, '\0', size))
goto cert_fail; goto cert_fail_name;
} }
if (check_host_name((char *)peer_cn, host) < 0) if (check_host_name((char *)peer_cn, host) < 0)
goto cert_fail; goto cert_fail_name;
OPENSSL_free(peer_cn); OPENSSL_free(peer_cn);
...@@ -372,9 +372,9 @@ on_error: ...@@ -372,9 +372,9 @@ on_error:
OPENSSL_free(peer_cn); OPENSSL_free(peer_cn);
return ssl_set_error(ssl, 0); return ssl_set_error(ssl, 0);
cert_fail: cert_fail_name:
OPENSSL_free(peer_cn); OPENSSL_free(peer_cn);
giterr_set(GITERR_SSL, "Certificate host name check failed"); giterr_set(GITERR_SSL, "hostname does not match certificate");
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment