19template <
typename Fun>
30 const char *strCat =
"unknown";
39 strCat =
"want-write";
79template <
typename Fun>
84 const auto fd = transport.
fd;
85 auto connection =
fd_table[fd].ssl.get();
88 const auto callResult = ioCall(connection);
89 const auto xerrno = errno;
91 debugs(83, 5, callResult <<
'/' << xerrno <<
" for TLS connection " <<
92 static_cast<void*
>(connection) <<
" over " << transport);
98 const auto ioError = SSL_get_error(connection, callResult);
103 case SSL_ERROR_WANT_READ:
106 case SSL_ERROR_WANT_WRITE:
118 errorDetail =
new ErrorDetail(topError, ioError, xerrno);
119 if (
const auto serverCert = SSL_get_peer_certificate(connection))
126 case SSL_ERROR_SYSCALL:
127 if (callResult == 0) {
128 ioResult.errorDescription =
"peer aborted";
130 ioResult.errorDescription =
"system call failure";
131 ioResult.important = (xerrno == ECONNRESET);
135 case SSL_ERROR_ZERO_RETURN:
137 ioResult.errorDescription =
"peer closed";
138 ioResult.important =
true;
143 ioResult.errorDescription =
"failure";
144 ioResult.important =
true;
150 if (callResult == GNUTLS_E_SUCCESS) {
152 const auto desc = gnutls_session_get_desc(connection);
153 debugs(83, 2,
"TLS session info: " << desc);
160 const auto descIn = gnutls_handshake_get_last_in(connection);
161 debugs(83, 2,
"handshake IN: " << gnutls_handshake_description_get_name(descIn));
162 const auto descOut = gnutls_handshake_get_last_out(connection);
163 debugs(83, 2,
"handshake OUT: " << gnutls_handshake_description_get_name(descOut));
165 if (callResult == GNUTLS_E_WARNING_ALERT_RECEIVED) {
166 const auto alert = gnutls_alert_get(connection);
171 if (!gnutls_error_is_fatal(callResult)) {
172 const auto reading = gnutls_record_get_direction(connection) == 0;
181 ioResult.errorDescription =
"failure";
188 "Unexpected TLS I/O in Squid built without a TLS/SSL library");
201 return SSL_accept(tlsConn);
203 return gnutls_handshake(tlsConn);
205 return sizeof(tlsConn);
216 return SSL_connect(tlsConn);
218 return gnutls_handshake(tlsConn);
220 return sizeof(tlsConn);
void setPeerCertificate(const CertPointer &)
a summary a TLS I/O operation outcome
Category category
primary outcome classification
bool important
whether the error was serious/unusual
void print(std::ostream &os) const
const char * errorDescription
a brief description of an error
#define debugs(SECTION, LEVEL, CONTENT)
int ssl_ex_index_ssl_error_detail
Network/connection security abstraction layer.
static IoResult Handshake(Comm::Connection &, ErrorCode, Fun)
IoResult Accept(Comm::Connection &transport)
accept a TLS connection over the specified to-Squid transport connection
int ErrorCode
Squid-defined error code (<0), an error code returned by X.509 API, or zero.
IoResult Connect(Comm::Connection &transport)
establish a TLS connection over the specified from-Squid transport connection
SessionPointer::element_type * ConnectionPointer
Security::LockingPointer< X509, X509_free_cpp, HardFun< int, X509 *, X509_up_ref > > CertPointer
void ForgetErrors()
clear any errors that a TLS library has accumulated in its global storage
void ForgetErrors()
Clear any errors accumulated by OpenSSL in its global storage.
@ SQUID_TLS_ERR_CONNECT
failure to establish a connection with a TLS server
@ SQUID_TLS_ERR_ACCEPT
failure to accept a connection from a TLS client
std::ostream & ForceAlert(std::ostream &s)