| 982 | Future<Void> acceptHandshake() override { return acceptHandshakeWrapper(Reference<SSLConnection>::addRef(this)); } |
| 983 | |
| 984 | ACTOR static void doConnectHandshake(Reference<SSLConnection> self, Promise<Void> connected) { |
| 985 | state Hold<int> holder; |
| 986 | |
| 987 | try { |
| 988 | Future<Void> onHandshook; |
| 989 | ConfigureSSLStream(N2::g_net2->activeTlsPolicy, self->ssl_sock, [this](bool verifyOk) { |
| 990 | self->has_trusted_peer = verifyOk; |
| 991 | }); |
| 992 | |
| 993 | // If the background handshakers are not all busy, use one |
| 994 | if (N2::g_net2->sslPoolHandshakesInProgress < N2::g_net2->sslHandshakerThreadsStarted) { |
| 995 | holder = Hold(&N2::g_net2->sslPoolHandshakesInProgress); |
| 996 | auto handshake = |
| 997 | new SSLHandshakerThread::Handshake(self->ssl_sock, boost::asio::ssl::stream_base::client); |
| 998 | onHandshook = handshake->done.getFuture(); |
| 999 | N2::g_net2->sslHandshakerPool->post(handshake); |
| 1000 | } else { |
| 1001 | // Otherwise use flow network thread |
| 1002 | BindPromise p("N2_ConnectHandshakeError", self->id); |
| 1003 | onHandshook = p.getFuture(); |
| 1004 | self->ssl_sock.async_handshake(boost::asio::ssl::stream_base::client, std::move(p)); |
| 1005 | } |
| 1006 | wait(onHandshook); |
| 1007 | wait(delay(0, TaskPriority::Handshake)); |
| 1008 | connected.send(Void()); |
| 1009 | } catch (...) { |
| 1010 | self->closeSocket(); |
| 1011 | connected.sendError(connection_failed()); |
| 1012 | } |
| 1013 | } |
| 1014 | |
| 1015 | ACTOR static Future<Void> connectHandshakeWrapper(Reference<SSLConnection> self) { |
| 1016 | wait(g_network->networkInfo.handshakeLock->take()); |
no test coverage detected