Clear OpenSSL error queue after failed X509_STORE_load_locations() call.
authorHeikki Linnakangas
Fri, 7 Oct 2016 09:53:45 +0000 (12:53 +0300)
committerHeikki Linnakangas
Fri, 7 Oct 2016 09:53:45 +0000 (12:53 +0300)
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.

src/interfaces/libpq/fe-secure.c

index a939a29743d894844c296fb0704c5772953eddf7..011042f03ee6482321c38a180ad8e22b4ba54d77 100644 (file)
@@ -1120,6 +1120,7 @@ initialize_SSL(PGconn *conn)
 #endif
            }
            /* if not found, silently ignore;  we do not require CRL */
+           ERR_clear_error();
        }
        have_rootcert = true;
    }