A simple PeerConnector for SSL/TLS cache_peers. No SslBump capabilities. More...

#include <BlindPeerConnector.h>

Inheritance diagram for Security::BlindPeerConnector:
Collaboration diagram for Security::BlindPeerConnector:

Public Types

typedef CbcPointer< PeerConnectorPointer
 

Public Member Functions

 BlindPeerConnector (HttpRequestPointer &aRequest, const Comm::ConnectionPointer &aServerConn, AsyncCall::Pointer &aCallback, const AccessLogEntryPointer &alp, const time_t timeout=0)
 
virtual bool initialize (Security::SessionPointer &)
 
virtual Security::ContextPointer getTlsContext ()
 Return the configured TLS context object. More...
 
virtual void noteNegotiationDone (ErrorState *)
 
bool canBeCalled (AsyncCall &call) const
 whether we can be called More...
 
void callStart (AsyncCall &call)
 
virtual void callEnd ()
 called right after the called job method More...
 
virtual void callException (const std::exception &e)
 called when the job throws during an async call More...
 
virtual void * toCbdata ()=0
 

Static Public Member Functions

static Pointer Start (AsyncJob *job)
 starts a freshly created job (i.e., makes the job asynchronous) More...
 

Protected Member Functions

virtual void start ()
 Preps connection and SSL state. Calls negotiate(). More...
 
virtual bool doneAll () const
 whether positive goal has been reached More...
 
virtual void swanSong ()
 
virtual const char * status () const
 internal cleanup; do not call directly More...
 
void commCloseHandler (const CommCloseCbParams &params)
 The comm_close callback handler. More...
 
void connectionClosed (const char *reason)
 Inform us that the connection is closed. Does the required clean-up. More...
 
bool prepareSocket ()
 
void negotiate ()
 
bool sslFinalized ()
 
void handleNegotiateError (const int result)
 
void noteWantRead ()
 
bool checkForMissingCertificates ()
 
void startCertDownloading (SBuf &url)
 Start downloading procedure for the given URL. More...
 
void certDownloadingDone (SBuf &object, int status)
 Called by Downloader after a certificate object downloaded. More...
 
virtual void noteWantWrite ()
 
virtual void noteNegotiationError (const int result, const int ssl_error, const int ssl_lib_error)
 
const Comm::ConnectionPointerserverConnection () const
 mimics FwdState to minimize changes to FwdState::initiate/negotiateSsl More...
 
void bail (ErrorState *error)
 Return an error to the PeerConnector caller. More...
 
void callBack ()
 
void bypassCertValidator ()
 If called the certificates validator will not used. More...
 
void recordNegotiationDetails ()
 
void deleteThis (const char *aReason)
 
void mustStop (const char *aReason)
 
bool done () const
 the job is destroyed in callEnd() when done() More...
 

Protected Attributes

HttpRequestPointer request
 peer connection trigger or cause More...
 
Comm::ConnectionPointer serverConn
 TCP connection to the peer. More...
 
AccessLogEntryPointer al
 info for the future access.log entry More...
 
AsyncCall::Pointer callback
 we call this with the results More...
 
const char * stopReason
 reason for forcing done() to be true More...
 
const char * typeName
 kid (leaf) class name, for debugging More...
 
AsyncCall::Pointer inCall
 the asynchronous call being handled, if any More...
 
const InstanceId< AsyncJobid
 job identifier More...
 

Private Member Functions

 CBDATA_CLASS (BlindPeerConnector)
 
void sslCrtvdHandleReply (Ssl::CertValidationResponsePointer)
 Process response from cert validator helper. More...
 
Security::CertErrorssslCrtvdCheckForErrors (Ssl::CertValidationResponse const &, Ssl::ErrorDetail *&)
 Check SSL errors returned from cert validator against sslproxy_cert_error access list. More...
 
void negotiateSsl ()
 Comm::SetSelect() callback. Direct calls tickle/resume negotiations. More...
 

Static Private Member Functions

static void NegotiateSsl (int fd, void *data)
 A wrapper for Comm::SetSelect() notifications. More...
 

Private Attributes

AsyncCall::Pointer closeHandler
 we call this when the connection closed More...
 
time_t negotiationTimeout
 the SSL connection timeout to use More...
 
time_t startTime
 when the peer connector negotiation started More...
 
bool useCertValidator_
 
std::queue< SBufurlsOfMissingCerts
 The list of URLs where missing certificates should be downloaded. More...
 
unsigned int certsDownloads
 the number of downloaded missing certificates More...
 

Static Private Attributes

static const unsigned int MaxCertsDownloads = 10
 The maximum allowed missing certificates downloads. More...
 
static const unsigned int MaxNestedDownloads = 3
 The maximum allowed nested certificates downloads. More...
 

Detailed Description

Definition at line 20 of file BlindPeerConnector.h.

Member Typedef Documentation

◆ Pointer

Definition at line 68 of file PeerConnector.h.

Constructor & Destructor Documentation

◆ BlindPeerConnector()

Security::BlindPeerConnector::BlindPeerConnector ( HttpRequestPointer aRequest,
const Comm::ConnectionPointer aServerConn,
AsyncCall::Pointer aCallback,
const AccessLogEntryPointer alp,
const time_t  timeout = 0 
)
inline

Definition at line 23 of file BlindPeerConnector.h.

References Security::PeerConnector::request.

Member Function Documentation

◆ bail()

void Security::PeerConnector::bail ( ErrorState error)
protectedinherited

◆ bypassCertValidator()

void Security::PeerConnector::bypassCertValidator ( )
inlineprotectedinherited

Definition at line 170 of file PeerConnector.h.

References Security::PeerConnector::useCertValidator_.

◆ callBack()

void Security::PeerConnector::callBack ( )
protectedinherited

Callback the caller class, and pass the ready to communicate secure connection or an error if PeerConnector failed.

Definition at line 558 of file PeerConnector.cc.

References Security::PeerConnector::CbDialer::answer(), callback, comm_remove_close_handler(), Security::EncryptorAnswer::conn, debugs, AsyncCall::getDialer(), Must, NULL, and ScheduleCallHere.

◆ callEnd()

void AsyncJob::callEnd ( )
virtualinherited

◆ callException()

◆ callStart()

void AsyncJob::callStart ( AsyncCall call)
inherited

◆ canBeCalled()

bool AsyncJob::canBeCalled ( AsyncCall call) const
inherited

Definition at line 101 of file AsyncJob.cc.

References AsyncCall::cancel(), debugs, HERE(), AsyncJob::inCall, and NULL.

◆ CBDATA_CLASS()

Security::BlindPeerConnector::CBDATA_CLASS ( BlindPeerConnector  )
private

◆ certDownloadingDone()

void Security::PeerConnector::certDownloadingDone ( SBuf object,
int  status 
)
protectedinherited

◆ checkForMissingCertificates()

bool Security::PeerConnector::checkForMissingCertificates ( )
protectedinherited

Run the certificates list sent by the SSL server and check if there are missing certificates. Adds to the urlOfMissingCerts list the URLS of missing certificates if this information provided by the issued certificates with Authority Info Access extension.

Definition at line 685 of file PeerConnector.cc.

References BIO_get_data(), debugs, fd_table, Ssl::missingChainCertificatesUrls(), Downloader::nestedLevel(), and request().

◆ commCloseHandler()

void Security::PeerConnector::commCloseHandler ( const CommCloseCbParams params)
protectedinherited

◆ connectionClosed()

void Security::PeerConnector::connectionClosed ( const char *  reason)
protectedinherited

Definition at line 79 of file PeerConnector.cc.

References callback, debugs, and NULL.

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)
protectedinherited

◆ done()

bool AsyncJob::done ( ) const
protectedinherited

◆ doneAll()

bool Security::PeerConnector::doneAll ( ) const
protectedvirtualinherited

Reimplemented from AsyncJob.

Definition at line 52 of file PeerConnector.cc.

References callback, and AsyncJob::doneAll().

◆ getTlsContext()

◆ handleNegotiateError()

void Security::PeerConnector::handleNegotiateError ( const int  result)
protectedinherited

Called when the negotiation step aborted because data needs to be transferred to/from server or on error. In the first case setups the appropriate Comm::SetSelect handler. In second case fill an error and report to the PeerConnector caller.

Definition at line 384 of file PeerConnector.cc.

References DBG_IMPORTANT, debugs, fd_table, and Must.

◆ initialize()

bool Security::BlindPeerConnector::initialize ( Security::SessionPointer serverSession)
virtual

Calls parent initialize(), configures the created TLS session object to try and reuse a TLS session and sets the hostname to use for certificate validation

Returns
true on successful initialization

Reimplemented from Security::PeerConnector.

Definition at line 33 of file BlindPeerConnector.cc.

References assert, debugs, Security::PeerOptions::encryptTransport, Security::PeerConnector::initialize(), SBuf::isEmpty(), request(), CachePeer::secure, Ssl::setClientSNI(), Security::SetSessionResumeData(), ssl_ex_index_server, Security::PeerOptions::sslDomain, CachePeer::sslSession, and _request::url.

◆ mustStop()

◆ negotiate()

void Security::PeerConnector::negotiate ( )
protectedinherited

Performs a single secure connection negotiation step. It is called multiple times untill the negotiation finishes or aborts.

Definition at line 164 of file PeerConnector.cc.

References debugs, fd_table, and Comm::IsConnOpen().

◆ negotiateSsl()

void Security::PeerConnector::negotiateSsl ( )
privateinherited

Definition at line 377 of file PeerConnector.cc.

References CallJobHere.

◆ NegotiateSsl()

void Security::PeerConnector::NegotiateSsl ( int  fd,
void *  data 
)
staticprivateinherited

Definition at line 367 of file PeerConnector.cc.

References data.

◆ noteNegotiationDone()

void Security::BlindPeerConnector::noteNegotiationDone ( ErrorState error)
virtual

On error calls peerConnectFailed(). On success store the used TLS session for later use.

Reimplemented from Security::PeerConnector.

Definition at line 66 of file BlindPeerConnector.cc.

References debugs, error(), fd_table, Security::MaybeGetSessionResumeData(), and peerConnectFailed().

◆ noteNegotiationError()

void Security::PeerConnector::noteNegotiationError ( const int  result,
const int  ssl_error,
const int  ssl_lib_error 
)
protectedvirtualinherited

Called when the SSL_connect function aborts with an SSL negotiation error

Parameters
resultthe SSL_connect return code
ssl_errorthe error code returned from the SSL_get_error function
ssl_lib_errorthe error returned from the ERR_Get_Error function

Reimplemented in Ssl::PeekingPeerConnector.

Definition at line 493 of file PeerConnector.cc.

References DBG_IMPORTANT, debugs, ERR_SECURE_CONNECT_FAIL, Security::ErrorString(), fd_table, ErrorState::NewForwarding(), NULL, request(), SQUID_ERR_SSL_HANDSHAKE, and ssl_ex_index_ssl_error_detail.

Referenced by Ssl::PeekingPeerConnector::noteNegotiationError().

◆ noteWantRead()

void Security::PeerConnector::noteWantRead ( )
protectedinherited

Called when the openSSL SSL_connect fnction request more data from the remote SSL server. Sets the read timeout and sets the Squid COMM_SELECT_READ handler.

Definition at line 448 of file PeerConnector.cc.

References BIO_get_data(), COMM_SELECT_READ, commSetConnTimeout(), DBG_IMPORTANT, debugs, fd_table, Comm::MortalReadTimeout(), Store::nil, and Comm::SetSelect().

◆ noteWantWrite()

void Security::PeerConnector::noteWantWrite ( )
protectedvirtualinherited

Called when the openSSL SSL_connect function needs to write data to the remote SSL server. Sets the Squid COMM_SELECT_WRITE handler.

Reimplemented in Ssl::PeekingPeerConnector.

Definition at line 484 of file PeerConnector.cc.

References COMM_SELECT_WRITE, debugs, and Comm::SetSelect().

Referenced by Ssl::PeekingPeerConnector::checkForPeekAndSpliceMatched(), and Ssl::PeekingPeerConnector::noteWantWrite().

◆ prepareSocket()

bool Security::PeerConnector::prepareSocket ( )
protectedinherited

Sets up TCP socket-related notification callbacks if things go wrong. If socket already closed return false, else install the comm_close handler to monitor the socket.

Definition at line 87 of file PeerConnector.cc.

References comm_add_close_handler(), Security::PeerConnector::commCloseHandler(), debugs, fd_table, Comm::IsConnOpen(), and JobCallback.

◆ recordNegotiationDetails()

void Security::PeerConnector::recordNegotiationDetails ( )
protectedinherited

Called after negotiation finishes to record connection details for logging

Definition at line 146 of file PeerConnector.cc.

References BIO_get_data(), and fd_table.

◆ serverConnection()

const Comm::ConnectionPointer& Security::PeerConnector::serverConnection ( ) const
inlineprotectedinherited

Definition at line 161 of file PeerConnector.h.

References Security::PeerConnector::serverConn.

Referenced by getTlsContext().

◆ sslCrtvdCheckForErrors()

Security::CertErrors * Security::PeerConnector::sslCrtvdCheckForErrors ( Ssl::CertValidationResponse const &  resp,
Ssl::ErrorDetail *&  errDetails 
)
privateinherited

◆ sslCrtvdHandleReply()

◆ sslFinalized()

bool Security::PeerConnector::sslFinalized ( )
protectedinherited

Called after negotiation has finished. Cleans up TLS/SSL state. Returns false if we are now waiting for the certs validation job. Otherwise, returns true, regardless of negotiation success/failure.

Definition at line 211 of file PeerConnector.cc.

References asyncCall(), DBG_IMPORTANT, debugs, Ssl::CertValidationRequest::domainName, ERR_GATEWAY_FAILURE, Ssl::CertValidationRequest::errors, fd_table, request(), Http::scInternalServerError, Ssl::CertValidationRequest::ssl, ssl_ex_index_server, ssl_ex_index_ssl_errors, Security::PeerConnector::sslCrtvdHandleReply(), Ssl::CertValidationHelper::Submit(), and Ssl::TheConfig.

◆ start()

void Security::PeerConnector::start ( )
protectedvirtualinherited

Reimplemented from AsyncJob.

Definition at line 59 of file PeerConnector.cc.

References debugs, and AsyncJob::start().

◆ Start()

◆ startCertDownloading()

void Security::PeerConnector::startCertDownloading ( SBuf url)
protectedinherited

◆ status()

const char * Security::PeerConnector::status ( ) const
protectedvirtualinherited

for debugging, starts with space

Reimplemented from AsyncJob.

Definition at line 591 of file PeerConnector.cc.

References buf, and NULL.

◆ swanSong()

void Security::PeerConnector::swanSong ( )
protectedvirtualinherited

◆ toCbdata()

virtual void* CbdataParent::toCbdata ( )
pure virtualinherited

Member Data Documentation

◆ al

AccessLogEntryPointer Security::PeerConnector::al
protectedinherited

Definition at line 178 of file PeerConnector.h.

◆ callback

AsyncCall::Pointer Security::PeerConnector::callback
protectedinherited

Definition at line 179 of file PeerConnector.h.

Referenced by Security::PeerConnector::PeerConnector().

◆ certsDownloads

unsigned int Security::PeerConnector::certsDownloads
privateinherited

Definition at line 206 of file PeerConnector.h.

◆ closeHandler

AsyncCall::Pointer Security::PeerConnector::closeHandler
privateinherited

Definition at line 200 of file PeerConnector.h.

◆ id

const InstanceId<AsyncJob> AsyncJob::id
protectedinherited

Definition at line 72 of file AsyncJob.h.

◆ inCall

AsyncCall::Pointer AsyncJob::inCall
protectedinherited

◆ MaxCertsDownloads

const unsigned int Security::PeerConnector::MaxCertsDownloads = 10
staticprivateinherited

Definition at line 196 of file PeerConnector.h.

◆ MaxNestedDownloads

const unsigned int Security::PeerConnector::MaxNestedDownloads = 3
staticprivateinherited

Definition at line 198 of file PeerConnector.h.

◆ negotiationTimeout

time_t Security::PeerConnector::negotiationTimeout
privateinherited

Definition at line 201 of file PeerConnector.h.

◆ request

HttpRequestPointer Security::PeerConnector::request
protectedinherited

◆ serverConn

Comm::ConnectionPointer Security::PeerConnector::serverConn
protectedinherited

Definition at line 177 of file PeerConnector.h.

Referenced by Security::PeerConnector::serverConnection().

◆ startTime

time_t Security::PeerConnector::startTime
privateinherited

Definition at line 202 of file PeerConnector.h.

◆ stopReason

const char* AsyncJob::stopReason
protectedinherited

◆ typeName

◆ urlsOfMissingCerts

std::queue<SBuf> Security::PeerConnector::urlsOfMissingCerts
privateinherited

Definition at line 205 of file PeerConnector.h.

◆ useCertValidator_

bool Security::PeerConnector::useCertValidator_
privateinherited

whether the certificate validator should bypassed

Definition at line 203 of file PeerConnector.h.

Referenced by Security::PeerConnector::bypassCertValidator().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors