From: Heikki Linnakangas Date: Fri, 7 Oct 2016 09:53:40 +0000 (+0300) Subject: Clear OpenSSL error queue after failed X509_STORE_load_locations() call. X-Git-Tag: REL9_6_1~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4d3ecbfee9dbe34fe20991a5a402b1f949814928;p=postgresql Clear OpenSSL error queue after failed X509_STORE_load_locations() call. Leaving the error in the error queue used to be harmless, because the X509_STORE_load_locations() call used to be the last step in initialize_SSL(), and we would clear the queue before the next SSL_connect() call. But previous commit moved things around. The symptom was that if a CRL file was not found, and one of the subsequent initialization steps, like loading the client certificate or private key, failed, we would incorrectly print the "no such file" error message from the earlier X509_STORE_load_locations() call as the reason. Backpatch to all supported versions, like the previous patch. --- diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index 18300f7776..cdb006409d 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -1000,6 +1000,7 @@ initialize_SSL(PGconn *conn) #endif } /* if not found, silently ignore; we do not require CRL */ + ERR_clear_error(); } have_rootcert = true; }