]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix server_cert_fingerprint on cert validator-reported errors (#522)
authorChristos Tsantilas <christos@chtsanti.net>
Wed, 25 Dec 2019 17:21:30 +0000 (17:21 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Sun, 19 Jan 2020 08:56:48 +0000 (21:56 +1300)
The server_cert_fingerprint ACL mismatched when sslproxy_cert_error
directive was applied to validation errors reported by the certificate
validator because the ACL could not find the server certificate.

This is a Measurement Factory project.

src/acl/FilledChecklist.h
src/acl/ServerCertificate.cc
src/security/PeerConnector.cc

index 9641c4ba0be9be901086603fbfdca8a56e395ef9..39cceb52e72192a970ee56aed0c8be35f3fc6183 100644 (file)
@@ -84,7 +84,10 @@ public:
 
     /// SSL [certificate validation] errors, in undefined order
     const Security::CertErrors *sslErrors;
-    /// The peer certificate
+
+    /// Peer certificate being checked by ssl_verify_cb() and by
+    /// Security::PeerConnector class. In other contexts, the peer
+    /// certificate is retrieved via ALE or ConnStateData::serverBump.
     Security::CertPointer serverCert;
 
     AccessLogEntry::Pointer al; ///< info for the future access.log, and external ACL
index 1246306d37df3364d5cb6d6c77f3d2b06fc96247..f5aeafde9fc9a20421183f843c9dba9d504521c1 100644 (file)
@@ -24,7 +24,10 @@ ACLServerCertificateStrategy::match(ACLData<MatchType> * &data, ACLFilledCheckli
     Security::CertPointer cert;
     if (checklist->serverCert)
         cert = checklist->serverCert;
-    else if (checklist->conn() != NULL && checklist->conn()->serverBump())
+    else if (checklist->al && Comm::IsConnOpen(checklist->al->hier.tcpServer)) {
+        const auto ssl = fd_table[checklist->al->hier.tcpServer->fd].ssl.get();
+        cert.resetWithoutLocking(SSL_get_peer_certificate(ssl));
+    } else if (checklist->conn() && checklist->conn()->serverBump())
         cert = checklist->conn()->serverBump()->serverCert;
 
     if (!cert)
index 2ec5111982b58f2e8b59d24f14aa6d621d592d73..fc5563cf56b8daae5a1da0b19b59a1a1bab07ca8 100644 (file)
@@ -322,14 +322,16 @@ Security::CertErrors *
 Security::PeerConnector::sslCrtvdCheckForErrors(Ssl::CertValidationResponse const &resp, Ssl::ErrorDetail *& errDetails)
 {
     ACLFilledChecklist *check = NULL;
+    Security::SessionPointer session(fd_table[serverConnection()->fd].ssl);
+
     if (acl_access *acl = ::Config.ssl_client.cert_error) {
         check = new ACLFilledChecklist(acl, request.getRaw(), dash_str);
         check->al = al;
         check->syncAle(request.getRaw(), nullptr);
+        check->serverCert.resetWithoutLocking(SSL_get_peer_certificate(session.get()));
     }
 
     Security::CertErrors *errs = nullptr;
-    Security::SessionPointer session(fd_table[serverConnection()->fd].ssl);
     typedef Ssl::CertValidationResponse::RecvdErrors::const_iterator SVCRECI;
     for (SVCRECI i = resp.errors.begin(); i != resp.errors.end(); ++i) {
         debugs(83, 7, "Error item: " << i->error_no << " " << i->error_reason);