Go to the documentation of this file.
19 template <
typename Fun>
30 const char *strCat =
nullptr;
39 strCat =
"want-write";
45 os << (strCat ? strCat :
"unknown");
90 template <
typename Fun>
95 const auto fd = transport.
fd;
96 auto connection =
fd_table[fd].ssl.get();
99 const auto callResult = ioCall(connection);
100 const auto xerrno = errno;
102 debugs(83, 5, callResult <<
'/' << xerrno <<
" for TLS connection " <<
103 static_cast<void*
>(connection) <<
" over " << transport);
109 const auto ioError = SSL_get_error(connection, callResult);
114 case SSL_ERROR_WANT_READ:
117 case SSL_ERROR_WANT_WRITE:
129 errorDetail =
new ErrorDetail(topError, ioError, xerrno);
130 if (
const auto serverCert = SSL_get_peer_certificate(connection))
131 errorDetail->setPeerCertificate(
CertPointer(serverCert));
137 case SSL_ERROR_SYSCALL:
138 if (callResult == 0) {
139 ioResult.errorDescription =
"peer aborted";
141 ioResult.errorDescription =
"system call failure";
142 ioResult.important = (xerrno == ECONNRESET);
146 case SSL_ERROR_ZERO_RETURN:
148 ioResult.errorDescription =
"peer closed";
149 ioResult.important =
true;
154 ioResult.errorDescription =
"failure";
155 ioResult.important =
true;
161 if (callResult == GNUTLS_E_SUCCESS) {
163 const auto desc = gnutls_session_get_desc(connection);
164 debugs(83, 2,
"TLS session info: " << desc);
171 const auto descIn = gnutls_handshake_get_last_in(connection);
172 debugs(83, 2,
"handshake IN: " << gnutls_handshake_description_get_name(descIn));
173 const auto descOut = gnutls_handshake_get_last_out(connection);
174 debugs(83, 2,
"handshake OUT: " << gnutls_handshake_description_get_name(descOut));
176 if (callResult == GNUTLS_E_WARNING_ALERT_RECEIVED) {
177 const auto alert = gnutls_alert_get(connection);
182 if (!gnutls_error_is_fatal(callResult)) {
183 const auto reading = gnutls_record_get_direction(connection) == 0;
192 ioResult.errorDescription =
"failure";
199 "Unexpected TLS I/O in Squid built without a TLS/SSL library");
212 return SSL_accept(tlsConn);
214 return gnutls_handshake(tlsConn);
216 return sizeof(tlsConn);
227 return SSL_connect(tlsConn);
229 return gnutls_handshake(tlsConn);
231 return sizeof(tlsConn);
int ErrorCode
Squid-defined error code (<0), an error code returned by X.509 API, or zero.
void printDescription(std::ostream &) const
common part of printGist() and printWithExtras()
void printWithExtras(std::ostream &) const
Security::LockingPointer< X509, X509_free_cpp, HardFun< int, X509 *, X509_up_ref > > CertPointer
std::ostream & ForceAlert(std::ostream &s)
a summary a TLS I/O operation outcome
void printGist(std::ostream &) const
reports brief summary (on one line) suitable for low-level debugging
SessionPointer::element_type * ConnectionPointer
Category category
primary outcome classification
void ForgetErrors()
clear any errors that a TLS library has accumulated in its global storage
static IoResult Handshake(Comm::Connection &, ErrorCode, Fun)
static std::ostream & Extra(std::ostream &)
@ SQUID_TLS_ERR_CONNECT
failure to establish a connection with a TLS server
const char * errorDescription
a brief description of an error
IoResult Connect(Comm::Connection &transport)
establish a TLS connection over the specified from-Squid transport connection
void ForgetErrors()
Clear any errors accumulated by OpenSSL in its global storage.
@ SQUID_TLS_ERR_ACCEPT
failure to accept a connection from a TLS client
IoResult Accept(Comm::Connection &transport)
accept a TLS connection over the specified to-Squid transport connection
interface for supplying additional information about a transaction failure
Network/connection security abstraction layer.
#define debugs(SECTION, LEVEL, CONTENT)
int ssl_ex_index_ssl_error_detail