]> granicus.if.org Git - curl/commitdiff
openssl: handle lack of server cert when strict checking disabled
authorAlessandro Ghedini <alessandro@ghedini.me>
Fri, 21 Aug 2015 12:50:45 +0000 (14:50 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 21 Aug 2015 13:32:51 +0000 (15:32 +0200)
If strict certificate checking is disabled (CURLOPT_SSL_VERIFYPEER
and CURLOPT_SSL_VERIFYHOST are disabled) do not fail if the server
doesn't present a certificate at all.

Closes #392

lib/vtls/openssl.c

index 90e4c2b32a3cc551775a380ccdfe7f3cb74e21ad..8600c61846b192a724894d93f463f7ebbdef31b1 100644 (file)
@@ -2644,8 +2644,10 @@ static CURLcode servercert(struct connectdata *conn,
 
   connssl->server_cert = SSL_get_peer_certificate(connssl->handle);
   if(!connssl->server_cert) {
-    if(strict)
-      failf(data, "SSL: couldn't get peer certificate!");
+    if(!strict)
+      return CURLE_OK;
+
+    failf(data, "SSL: couldn't get peer certificate!");
     return CURLE_PEER_FAILED_VERIFICATION;
   }