Clear OpenSSL error stack after loading certificate file.
authorKyle Nekritz <knekritz@fb.com>
Fri, 20 Jan 2017 17:02:40 +0000 (09:02 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 20 Jan 2017 17:17:55 +0000 (09:17 -0800)
Summary: SSL_CTX_load_verify_locations interally end up using X509_load_cert_crt_file, which has an unchecked call to X509_STORE_add_cert. This can fail and add an error to the error stack without causing SSL_CTX_load_verify_locations to return an error.

Reviewed By: siyengar

Differential Revision: D4442017

fbshipit-source-id: a4cf7f5ee2c18d90d5d61baf3acb99ffca6b8af0

folly/io/async/SSLContext.cpp

index 7a0c9993fdc81dfe35085d1c9570fc2770e85c06..dd28da58fb7236629103f1bb0196a40af7ebe42a 100644 (file)
@@ -342,6 +342,7 @@ void SSLContext::loadTrustedCertificates(const char* path) {
   if (SSL_CTX_load_verify_locations(ctx_, path, nullptr) == 0) {
     throw std::runtime_error("SSL_CTX_load_verify_locations: " + getErrors());
   }
+  ERR_clear_error();
 }
 
 void SSLContext::loadTrustedCertificates(X509_STORE* store) {