MCPcopy Create free account
hub / github.com/apache/trafficserver / sslServerHandShakeEvent

Method sslServerHandShakeEvent

src/iocore/net/SSLNetVConnection.cc:1236–1488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1234}
1235
1236int
1237SSLNetVConnection::sslServerHandShakeEvent(int &err)
1238{
1239 // Continue on if we are in the invoked state. The hook has not yet reenabled
1240 if (this->is_invoked_state()) {
1241 return SSL_WAIT_FOR_HOOK;
1242 }
1243
1244 // Go do the preaccept hooks
1245 if (this->get_handshake_hook_state() == TLSEventSupport::SSLHandshakeHookState::HANDSHAKE_HOOKS_PRE) {
1246 if (this->invoke_tls_event() == 1) {
1247 return SSL_WAIT_FOR_HOOK;
1248 }
1249 }
1250
1251 // If a blind tunnel was requested in the pre-accept calls, convert.
1252 // Again no data has been exchanged, so we can go directly
1253 // without data replay.
1254 // Note we can't arrive here if a hook is active.
1255
1256 if (SslVConnOp::SSL_HOOK_OP_TUNNEL == hookOpRequested) {
1257 this->attributes = HttpProxyPort::TRANSPORT_BLIND_TUNNEL;
1258 SSL_free(this->ssl);
1259 this->ssl = nullptr;
1260 // Don't mark the handshake as complete yet,
1261 // Will be checking for that flag not being set after
1262 // we get out of this callback, and then will shuffle
1263 // over the buffered handshake packets to the O.S.
1264 return EVENT_DONE;
1265 } else if (SslVConnOp::SSL_HOOK_OP_TERMINATE == hookOpRequested) {
1266 sslHandshakeStatus = SSLHandshakeStatus::SSL_HANDSHAKE_DONE;
1267 return EVENT_DONE;
1268 }
1269
1270 Dbg(dbg_ctl_ssl, "Go on with the handshake state=%s",
1271 TLSEventSupport::get_ssl_handshake_hook_state_name(this->get_handshake_hook_state()));
1272
1273 // All the pre-accept hooks have completed, proceed with the actual accept.
1274 bool const in_client_hello =
1275 this->get_handshake_hook_state() == TLSEventSupport::SSLHandshakeHookState::HANDSHAKE_HOOKS_CLIENT_HELLO;
1276 // We only feed CLIENT_HELLO bytes into our temporary buffers. If we are past
1277 // the CLIENT_HELLO, then no need to buffer.
1278 if (in_client_hello && this->handShakeReader) {
1279 if (BIO_eof(SSL_get_rbio(this->ssl))) { // No more data in the buffer
1280 // Is this the first read?
1281#if TS_USE_TLS_ASYNC
1282 if (SSLConfigParams::async_handshake_enabled) {
1283 SSL_set_mode(ssl, SSL_MODE_ASYNC);
1284 }
1285#endif
1286
1287 Dbg(dbg_ctl_ssl, "%p reading off the socket into our buffers", this);
1288 // Read from socket to fill in the BIO buffer with the
1289 // raw handshake data before calling the ssl accept calls.
1290 int retval = this->read_raw_data();
1291 if (retval < 0) {
1292 if (retval == -EAGAIN) {
1293 // No data at the moment, hang tight

Callers

nothing calls this directly

Calls 15

read_raw_dataMethod · 0.95
_ssl_acceptMethod · 0.95
reenableMethod · 0.95
_migrateFromSSLMethod · 0.95
get_PollDescriptorFunction · 0.85
this_ethreadFunction · 0.85
get_NetHandlerFunction · 0.85
SSLErrorNameFunction · 0.85
debug_certificate_nameFunction · 0.85
incrementFunction · 0.85
is_invoked_stateMethod · 0.80

Tested by

no test coverage detected