]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: remove Security::SessionPtr type
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 15 Sep 2016 10:00:37 +0000 (22:00 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 15 Sep 2016 10:00:37 +0000 (22:00 +1200)
raw-pointers cause more trouble than they are worth especially when
mixed with smart pointers. Use the Security::SessionPointer type instead.

TODO: there are still SSL* pointer uses to be removed or converted to
      Security::SessionPointer

src/client_side.cc
src/security/LockingPointer.h
src/security/NegotiationHistory.cc
src/security/NegotiationHistory.h
src/security/PeerConnector.cc
src/security/Session.h
src/ssl/PeekingPeerConnector.cc
src/tests/stub_libsecurity.cc

index 772bad9f9a995295c69f61505a1055b75ea55e36..d94ce1904b23ccb6c9b1dcc34524767e94bc8a6e 100644 (file)
@@ -2649,9 +2649,6 @@ static void
 clientNegotiateSSL(int fd, void *data)
 {
     ConnStateData *conn = (ConnStateData *)data;
-    X509 *client_cert;
-    auto ssl = fd_table[fd].ssl.get();
-
     int ret;
     if ((ret = Squid_SSL_accept(conn, clientNegotiateSSL)) <= 0) {
         if (ret < 0) // An error
@@ -2659,16 +2656,21 @@ clientNegotiateSSL(int fd, void *data)
         return;
     }
 
-    if (Security::SessionIsResumed(fd_table[fd].ssl)) {
-        debugs(83, 2, "clientNegotiateSSL: Session " << SSL_get_session(ssl) <<
-               " reused on FD " << fd << " (" << fd_table[fd].ipaddr << ":" << (int)fd_table[fd].remote_port << ")");
+    Security::SessionPointer session(fd_table[fd].ssl);
+    if (Security::SessionIsResumed(session)) {
+        debugs(83, 2, "Session " << SSL_get_session(session.get()) <<
+               " reused on FD " << fd << " (" << fd_table[fd].ipaddr <<
+               ":" << (int)fd_table[fd].remote_port << ")");
     } else {
         if (Debug::Enabled(83, 4)) {
             /* Write out the SSL session details.. actually the call below, but
              * OpenSSL headers do strange typecasts confusing GCC.. */
             /* PEM_write_SSL_SESSION(debug_log, SSL_get_session(ssl)); */
 #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x00908000L
-            PEM_ASN1_write((i2d_of_void *)i2d_SSL_SESSION, PEM_STRING_SSL_SESSION, debug_log, (char *)SSL_get_session(ssl), NULL,NULL,0,NULL,NULL);
+            PEM_ASN1_write(reinterpret_cast<i2d_of_void *>(i2d_SSL_SESSION),
+                           PEM_STRING_SSL_SESSION, debug_log,
+                           static_cast<char *>(SSL_get_session(session.get())),
+                           nullptr, nullptr, 0, nullptr, nullptr);
 
 #elif (ALLOW_ALWAYS_SSL_SESSION_DETAIL == 1)
 
@@ -2679,47 +2681,48 @@ clientNegotiateSSL(int fd, void *data)
             * Because there are two possible usable cast, if you get an error here, try the other
             * commented line. */
 
-            PEM_ASN1_write((int(*)())i2d_SSL_SESSION, PEM_STRING_SSL_SESSION, debug_log, (char *)SSL_get_session(ssl), NULL,NULL,0,NULL,NULL);
-            /* PEM_ASN1_write((int(*)(...))i2d_SSL_SESSION, PEM_STRING_SSL_SESSION, debug_log, (char *)SSL_get_session(ssl), NULL,NULL,0,NULL,NULL); */
-
+            PEM_ASN1_write((int(*)())i2d_SSL_SESSION, PEM_STRING_SSL_SESSION,
+                           debug_log,
+                           static_cast<char *>(SSL_get_session(session.get())),
+                           nullptr, nullptr, 0, nullptr, nullptr);
+            /* PEM_ASN1_write((int(*)(...))i2d_SSL_SESSION, PEM_STRING_SSL_SESSION,
+                           debug_log,
+                           static_cast<char *>(SSL_get_session(session.get())),
+                           nullptr, nullptr, 0, nullptr, nullptr);
+             */
 #else
-
-            debugs(83, 4, "With " OPENSSL_VERSION_TEXT ", session details are available only defining ALLOW_ALWAYS_SSL_SESSION_DETAIL=1 in the source." );
+            debugs(83, 4, "With " OPENSSL_VERSION_TEXT ", session details are available only defining ALLOW_ALWAYS_SSL_SESSION_DETAIL=1 in the source.");
 
 #endif
             /* Note: This does not automatically fflush the log file.. */
         }
 
-        debugs(83, 2, "clientNegotiateSSL: New session " <<
-               SSL_get_session(ssl) << " on FD " << fd << " (" <<
-               fd_table[fd].ipaddr << ":" << (int)fd_table[fd].remote_port <<
-               ")");
+        debugs(83, 2, "New session " << SSL_get_session(session.get()) <<
+               " on FD " << fd << " (" << fd_table[fd].ipaddr << ":" <<
+               fd_table[fd].remote_port << ")");
     }
 
     // Connection established. Retrieve TLS connection parameters for logging.
-    conn->clientConnection->tlsNegotiations()->retrieveNegotiatedInfo(ssl);
+    conn->clientConnection->tlsNegotiations()->retrieveNegotiatedInfo(session);
 
-    client_cert = SSL_get_peer_certificate(ssl);
+    X509 *client_cert = SSL_get_peer_certificate(session.get());
 
-    if (client_cert != NULL) {
-        debugs(83, 3, "clientNegotiateSSL: FD " << fd <<
-               " client certificate: subject: " <<
+    if (client_cert) {
+        debugs(83, 3, "FD " << fd << " client certificate: subject: " <<
                X509_NAME_oneline(X509_get_subject_name(client_cert), 0, 0));
 
-        debugs(83, 3, "clientNegotiateSSL: FD " << fd <<
-               " client certificate: issuer: " <<
+        debugs(83, 3, "FD " << fd << " client certificate: issuer: " <<
                X509_NAME_oneline(X509_get_issuer_name(client_cert), 0, 0));
 
         X509_free(client_cert);
     } else {
-        debugs(83, 5, "clientNegotiateSSL: FD " << fd <<
-               " has no certificate.");
+        debugs(83, 5, "FD " << fd << " has no certificate.");
     }
 
 #if defined(TLSEXT_NAMETYPE_host_name)
     if (!conn->serverBump()) {
         // when in bumpClientFirst mode, get the server name from SNI
-        if (const char *server = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name))
+        if (const char *server = SSL_get_servername(session.get(), TLSEXT_NAMETYPE_host_name))
             conn->resetSslCommonName(server);
     }
 #endif
index f9ca101d98104b12ae059a4f1745b15454c68269..8ed9b34932490499819e69ca830a16bfe2cb8cda 100644 (file)
@@ -88,6 +88,8 @@ public:
     bool operator ==(const SelfType &o) const { return (o.get() == raw); }
     bool operator !=(const SelfType &o) const { return (o.get() != raw); }
 
+    T *operator ->() const { return raw; }
+
     /// Returns raw and possibly nullptr pointer
     T *get() const { return raw; }
 
index f6366052e9314675d3fd4c2e6e0960ad364aa3c2..104d061290145045a3ad3b8b3a56311c5594a2bf 100644 (file)
@@ -65,18 +65,18 @@ toProtocolVersion(const int v)
 #endif
 
 void
-Security::NegotiationHistory::retrieveNegotiatedInfo(Security::SessionPtr ssl)
+Security::NegotiationHistory::retrieveNegotiatedInfo(const Security::SessionPointer &session)
 {
 #if USE_OPENSSL
-    if ((cipher = SSL_get_current_cipher(ssl)) != NULL) {
+    if ((cipher = SSL_get_current_cipher(session.get()))) {
         // Set the negotiated version only if the cipher negotiated
         // else probably the negotiation is not completed and version
         // is not the final negotiated version
-        version_ = toProtocolVersion(ssl->version);
+        version_ = toProtocolVersion(session->version);
     }
 
     if (Debug::Enabled(83, 5)) {
-        BIO *b = SSL_get_rbio(ssl);
+        BIO *b = SSL_get_rbio(session.get());
         Ssl::Bio *bio = static_cast<Ssl::Bio *>(b->ptr);
         debugs(83, 5, "SSL connection info on FD " << bio->fd() <<
                " SSL version " << version_ <<
index 8e691123a7a55c6882961055a25a79de5507be31..269666080637174b621c6b9848b3641600cdd537 100644 (file)
@@ -21,7 +21,7 @@ public:
     NegotiationHistory();
 
     /// Extract negotiation information from TLS object
-    void retrieveNegotiatedInfo(Security::SessionPtr);
+    void retrieveNegotiatedInfo(const Security::SessionPointer &);
 
     /// Extract information from parser stored in TlsDetails  object
     void retrieveParsedInfo(Security::TlsDetails::Pointer const &details);
index 4aacb070ed2a0045299db047957d70b501702a37..977369a9fb147eb53cb9320c5b79b921e5cfa157 100644 (file)
@@ -151,14 +151,15 @@ Security::PeerConnector::setReadTimeout()
 void
 Security::PeerConnector::recordNegotiationDetails()
 {
-#if USE_OPENSSL
     const int fd = serverConnection()->fd;
-    Security::SessionPtr ssl = fd_table[fd].ssl.get();
+    Security::SessionPointer session(fd_table[fd].ssl);
 
     // retrieve TLS server negotiated information if any
-    serverConnection()->tlsNegotiations()->retrieveNegotiatedInfo(ssl);
+    serverConnection()->tlsNegotiations()->retrieveNegotiatedInfo(session);
+
+#if USE_OPENSSL
     // retrieve TLS parsed extra info
-    BIO *b = SSL_get_rbio(ssl);
+    BIO *b = SSL_get_rbio(session.get());
     Ssl::ServerBio *bio = static_cast<Ssl::ServerBio *>(b->ptr);
     if (const Security::TlsDetails::Pointer &details = bio->receivedHelloDetails())
         serverConnection()->tlsNegotiations()->retrieveParsedInfo(details);
@@ -199,20 +200,18 @@ Security::PeerConnector::sslFinalized()
 #if USE_OPENSSL
     if (Ssl::TheConfig.ssl_crt_validator && useCertValidator_) {
         const int fd = serverConnection()->fd;
-        Security::SessionPtr ssl = fd_table[fd].ssl.get();
+        Security::SessionPointer session(fd_table[fd].ssl);
 
         Ssl::CertValidationRequest validationRequest;
         // WARNING: Currently we do not use any locking for any of the
         // members of the Ssl::CertValidationRequest class. In this code the
         // Ssl::CertValidationRequest object used only to pass data to
         // Ssl::CertValidationHelper::submit method.
-        validationRequest.ssl = ssl;
+        validationRequest.ssl = session.get();
         validationRequest.domainName = request->url.host();
-        if (Security::CertErrors *errs = static_cast<Security::CertErrors *>(SSL_get_ex_data(ssl, ssl_ex_index_ssl_errors)))
+        if (Security::CertErrors *errs = static_cast<Security::CertErrors *>(SSL_get_ex_data(session.get(), ssl_ex_index_ssl_errors)))
             // validationRequest disappears on return so no need to cbdataReference
             validationRequest.errors = errs;
-        else
-            validationRequest.errors = NULL;
         try {
             debugs(83, 5, "Sending SSL certificate for validation to ssl_crtvd.");
             AsyncCall::Pointer call = asyncCall(83,5, "Security::PeerConnector::sslCrtvdHandleReply", Ssl::CertValidationHelper::CbDialer(this, &Security::PeerConnector::sslCrtvdHandleReply, nullptr));
@@ -254,9 +253,9 @@ Security::PeerConnector::sslCrtvdHandleReply(Ssl::CertValidationResponse::Pointe
 
     if (validationResponse->resultCode == ::Helper::Error) {
         if (Security::CertErrors *errs = sslCrtvdCheckForErrors(*validationResponse, errDetails)) {
-            Security::SessionPtr ssl = fd_table[serverConnection()->fd].ssl.get();
-            Security::CertErrors *oldErrs = static_cast<Security::CertErrors*>(SSL_get_ex_data(ssl, ssl_ex_index_ssl_errors));
-            SSL_set_ex_data(ssl, ssl_ex_index_ssl_errors,  (void *)errs);
+            Security::SessionPointer session(fd_table[serverConnection()->fd].ssl);
+            Security::CertErrors *oldErrs = static_cast<Security::CertErrors*>(SSL_get_ex_data(session.get(), ssl_ex_index_ssl_errors));
+            SSL_set_ex_data(session.get(), ssl_ex_index_ssl_errors,  (void *)errs);
             delete oldErrs;
         }
     } else if (validationResponse->resultCode != ::Helper::Okay)
@@ -298,7 +297,7 @@ Security::PeerConnector::sslCrtvdCheckForErrors(Ssl::CertValidationResponse cons
     }
 
     Security::CertErrors *errs = nullptr;
-    Security::SessionPtr ssl = fd_table[serverConnection()->fd].ssl.get();
+    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);
@@ -320,7 +319,7 @@ Security::PeerConnector::sslCrtvdCheckForErrors(Ssl::CertValidationResponse cons
             } else {
                 debugs(83, 5, "confirming SSL error " << i->error_no);
                 X509 *brokenCert = i->cert.get();
-                Security::CertPointer peerCert(SSL_get_peer_certificate(ssl));
+                Security::CertPointer peerCert(SSL_get_peer_certificate(session.get()));
                 const char *aReason = i->error_reason.empty() ? NULL : i->error_reason.c_str();
                 errDetails = new Ssl::ErrorDetail(i->error_no, peerCert.get(), brokenCert, aReason);
             }
@@ -357,8 +356,8 @@ Security::PeerConnector::handleNegotiateError(const int ret)
 #if USE_OPENSSL
     const int fd = serverConnection()->fd;
     unsigned long ssl_lib_error = SSL_ERROR_NONE;
-    Security::SessionPtr ssl = fd_table[fd].ssl.get();
-    const int ssl_error = SSL_get_error(ssl, ret);
+    Security::SessionPointer session(fd_table[fd].ssl);
+    const int ssl_error = SSL_get_error(session.get(), ret);
 
     switch (ssl_error) {
     case SSL_ERROR_WANT_READ:
@@ -390,8 +389,8 @@ Security::PeerConnector::noteWantRead()
 {
     const int fd = serverConnection()->fd;
 #if USE_OPENSSL
-    Security::SessionPtr ssl = fd_table[fd].ssl.get();
-    BIO *b = SSL_get_rbio(ssl);
+    Security::SessionPointer session(fd_table[fd].ssl);
+    BIO *b = SSL_get_rbio(session.get());
     Ssl::ServerBio *srvBio = static_cast<Ssl::ServerBio *>(b->ptr);
     if (srvBio->holdRead()) {
         if (srvBio->gotHello()) {
@@ -449,8 +448,8 @@ Security::PeerConnector::noteNegotiationError(const int ret, const int ssl_error
         anErr = new ErrorState(ERR_SECURE_CONNECT_FAIL, Http::scServiceUnavailable, NULL);
     anErr->xerrno = sysErrNo;
 
-    Security::SessionPtr ssl = fd_table[fd].ssl.get();
-    Ssl::ErrorDetail *errFromFailure = static_cast<Ssl::ErrorDetail *>(SSL_get_ex_data(ssl, ssl_ex_index_ssl_error_detail));
+    Security::SessionPointer session(fd_table[fd].ssl);
+    Ssl::ErrorDetail *errFromFailure = static_cast<Ssl::ErrorDetail *>(SSL_get_ex_data(session.get(), ssl_ex_index_ssl_error_detail));
     if (errFromFailure != NULL) {
         // The errFromFailure is attached to the ssl object
         // and will be released when ssl object destroyed.
@@ -458,7 +457,7 @@ Security::PeerConnector::noteNegotiationError(const int ret, const int ssl_error
         anErr->detail = new Ssl::ErrorDetail(*errFromFailure);
     } else {
         // server_cert can be NULL here
-        X509 *server_cert = SSL_get_peer_certificate(ssl);
+        X509 *server_cert = SSL_get_peer_certificate(session.get());
         anErr->detail = new Ssl::ErrorDetail(SQUID_ERR_SSL_HANDSHAKE, server_cert, NULL);
         X509_free(server_cert);
     }
@@ -579,8 +578,8 @@ Security::PeerConnector::certDownloadingDone(SBuf &obj, int downloadStatus)
 
     // get ServerBio from SSL object
     const int fd = serverConnection()->fd;
-    Security::SessionPtr ssl = fd_table[fd].ssl.get();
-    BIO *b = SSL_get_rbio(ssl);
+    Security::SessionPointer session(fd_table[fd].ssl);
+    BIO *b = SSL_get_rbio(session.get());
     Ssl::ServerBio *srvBio = static_cast<Ssl::ServerBio *>(b->ptr);
 
     // Parse Certificate. Assume that it is in DER format.
@@ -598,7 +597,7 @@ Security::PeerConnector::certDownloadingDone(SBuf &obj, int downloadStatus)
         if (const char *issuerUri = Ssl::uriOfIssuerIfMissing(cert,  certsList)) {
             urlsOfMissingCerts.push(SBuf(issuerUri));
         }
-        Ssl::SSL_add_untrusted_cert(ssl, cert);
+        Ssl::SSL_add_untrusted_cert(session.get(), cert);
     }
 
     // Check if there are URIs to download from and if yes start downloading
@@ -625,8 +624,8 @@ Security::PeerConnector::checkForMissingCertificates()
         return false;
 
     const int fd = serverConnection()->fd;
-    Security::SessionPtr ssl = fd_table[fd].ssl.get();
-    BIO *b = SSL_get_rbio(ssl);
+    Security::SessionPointer session(fd_table[fd].ssl);
+    BIO *b = SSL_get_rbio(session.get());
     Ssl::ServerBio *srvBio = static_cast<Ssl::ServerBio *>(b->ptr);
     const Security::CertList &certs = srvBio->serverCertificatesIfAny();
 
index e7ce105709ec4884745ff2b3c9ccbd6096bb63b9..7e5dd27f2d0d3b93175cfe3d4735f20deb6c0933 100644 (file)
 namespace Security {
 
 #if USE_OPENSSL
-typedef SSL* SessionPtr;
 CtoCpp1(SSL_free, SSL *);
 typedef LockingPointer<SSL, Security::SSL_free_cpp, CRYPTO_LOCK_SSL> SessionPointer;
 
 typedef std::unique_ptr<SSL_SESSION, HardFun<void, SSL_SESSION*, &SSL_SESSION_free>> SessionStatePointer;
 
 #elif USE_GNUTLS
-typedef gnutls_session_t SessionPtr;
 // Locks can be implemented attaching locks counter to gnutls_session_t
 // objects using the gnutls_session_set_ptr()/gnutls_session_get_ptr ()
 // library functions
@@ -49,8 +47,7 @@ typedef std::unique_ptr<gnutls_datum_t, HardFun<void, void*, &Security::squid_gn
 
 #else
 // use void* so we can check against NULL
-typedef void* SessionPtr;
-CtoCpp1(xfree, SessionPtr);
+CtoCpp1(xfree, void *);
 typedef LockingPointer<void, xfree_cpp, -1> SessionPointer;
 
 typedef std::unique_ptr<int> SessionStatePointer;
index d7ddaad5266f56015157aa84aa618f83097c2777..e86616820649762943079c25307e3b926a2d78d0 100644 (file)
@@ -63,8 +63,8 @@ Ssl::PeekingPeerConnector::checkForPeekAndSplice()
     acl_checklist->banAction(allow_t(ACCESS_ALLOWED, Ssl::bumpStare));
     acl_checklist->banAction(allow_t(ACCESS_ALLOWED, Ssl::bumpClientFirst));
     acl_checklist->banAction(allow_t(ACCESS_ALLOWED, Ssl::bumpServerFirst));
-    Security::SessionPtr ssl = fd_table[serverConn->fd].ssl.get();
-    BIO *b = SSL_get_rbio(ssl);
+    Security::SessionPointer session(fd_table[serverConn->fd].ssl);
+    BIO *b = SSL_get_rbio(session.get());
     Ssl::ServerBio *srvBio = static_cast<Ssl::ServerBio *>(b->ptr);
     if (!srvBio->canSplice())
         acl_checklist->banAction(allow_t(ACCESS_ALLOWED, Ssl::bumpSplice));
@@ -76,8 +76,8 @@ Ssl::PeekingPeerConnector::checkForPeekAndSplice()
 void
 Ssl::PeekingPeerConnector::checkForPeekAndSpliceMatched(const Ssl::BumpMode action)
 {
-    Security::SessionPtr ssl = fd_table[serverConn->fd].ssl.get();
-    BIO *b = SSL_get_rbio(ssl);
+    Security::SessionPointer session(fd_table[serverConn->fd].ssl);
+    BIO *b = SSL_get_rbio(session.get());
     Ssl::ServerBio *srvBio = static_cast<Ssl::ServerBio *>(b->ptr);
     debugs(83,5, "Will check for peek and splice on FD " << serverConn->fd);
 
@@ -217,10 +217,8 @@ Ssl::PeekingPeerConnector::initialize(Security::SessionPointer &serverSession)
 void
 Ssl::PeekingPeerConnector::noteNegotiationDone(ErrorState *error)
 {
-    Security::SessionPtr ssl = fd_table[serverConnection()->fd].ssl.get();
-
     // Check the list error with
-    if (!request->clientConnectionManager.valid() || ! ssl)
+    if (!request->clientConnectionManager.valid() || !fd_table[serverConnection()->fd].ssl)
         return;
 
     // remember the server certificate from the ErrorDetail object
@@ -263,8 +261,8 @@ void
 Ssl::PeekingPeerConnector::noteWantWrite()
 {
     const int fd = serverConnection()->fd;
-    Security::SessionPtr ssl = fd_table[fd].ssl.get();
-    BIO *b = SSL_get_rbio(ssl);
+    Security::SessionPointer session(fd_table[fd].ssl);
+    BIO *b = SSL_get_rbio(session.get());
     Ssl::ServerBio *srvBio = static_cast<Ssl::ServerBio *>(b->ptr);
 
     if ((srvBio->bumpMode() == Ssl::bumpPeek || srvBio->bumpMode() == Ssl::bumpStare) && srvBio->holdWrite()) {
@@ -280,8 +278,8 @@ void
 Ssl::PeekingPeerConnector::noteNegotiationError(const int result, const int ssl_error, const int ssl_lib_error)
 {
     const int fd = serverConnection()->fd;
-    Security::SessionPtr ssl = fd_table[fd].ssl.get();
-    BIO *b = SSL_get_rbio(ssl);
+    Security::SessionPointer session(fd_table[fd].ssl);
+    BIO *b = SSL_get_rbio(session.get());
     Ssl::ServerBio *srvBio = static_cast<Ssl::ServerBio *>(b->ptr);
 
     // In Peek mode, the ClientHello message sent to the server. If the
@@ -307,10 +305,10 @@ Ssl::PeekingPeerConnector::noteNegotiationError(const int result, const int ssl_
     // thus hiding them.
     // Abort if no certificate found probably because of malformed or
     // unsupported server Hello message (TODO: make configurable).
-    if (!SSL_get_ex_data(ssl, ssl_ex_index_ssl_error_detail) &&
+    if (!SSL_get_ex_data(session.get(), ssl_ex_index_ssl_error_detail) &&
             (srvBio->bumpMode() == Ssl::bumpPeek  || srvBio->bumpMode() == Ssl::bumpStare) && srvBio->holdWrite()) {
-        Security::CertPointer serverCert(SSL_get_peer_certificate(ssl));
-        if (serverCert.get()) {
+        Security::CertPointer serverCert(SSL_get_peer_certificate(session.get()));
+        if (serverCert) {
             debugs(81, 3, "Error ("  << ERR_error_string(ssl_lib_error, NULL) <<  ") but, hold write on SSL connection on FD " << fd);
             checkForPeekAndSplice();
             return;
@@ -329,9 +327,9 @@ Ssl::PeekingPeerConnector::handleServerCertificate()
 
     if (ConnStateData *csd = request->clientConnectionManager.valid()) {
         const int fd = serverConnection()->fd;
-        Security::SessionPtr ssl = fd_table[fd].ssl.get();
-        Security::CertPointer serverCert(SSL_get_peer_certificate(ssl));
-        if (!serverCert.get())
+        Security::SessionPointer session(fd_table[fd].ssl);
+        Security::CertPointer serverCert(SSL_get_peer_certificate(session.get()));
+        if (!serverCert)
             return;
 
         serverCertificateHandled = true;
@@ -352,10 +350,10 @@ Ssl::PeekingPeerConnector::serverCertificateVerified()
             serverCert.resetAndLock(serverBump->serverCert.get());
         else {
             const int fd = serverConnection()->fd;
-            Security::SessionPtr ssl = fd_table[fd].ssl.get();
-            serverCert.resetWithoutLocking(SSL_get_peer_certificate(ssl));
+            Security::SessionPointer session(fd_table[fd].ssl);
+            serverCert.resetWithoutLocking(SSL_get_peer_certificate(session.get()));
         }
-        if (serverCert.get()) {
+        if (serverCert) {
             csd->resetSslCommonName(Ssl::CommonHostName(serverCert.get()));
             debugs(83, 5, "HTTPS server CN: " << csd->sslCommonName() <<
                    " bumped: " << *serverConnection());
index 304d2bb17c7413365cc2600105a54dae720402f8..f570ff7c3ee8bae5518eb58ca27bcea954c10652 100644 (file)
@@ -33,7 +33,7 @@ bool Security::HandshakeParser::parseHello(const SBuf &) STUB_RETVAL(false)
 
 #include "security/NegotiationHistory.h"
 Security::NegotiationHistory::NegotiationHistory() STUB
-void Security::NegotiationHistory::retrieveNegotiatedInfo(Security::SessionPtr) STUB
+void Security::NegotiationHistory::retrieveNegotiatedInfo(const Security::SessionPointer &) STUB
 void Security::NegotiationHistory::retrieveParsedInfo(Security::TlsDetails::Pointer const &) STUB
 const char *Security::NegotiationHistory::cipherName() const STUB
 const char *Security::NegotiationHistory::printTlsVersion(AnyP::ProtocolVersion const &v) const STUB