void ConnectionManager(ServerGame& aGame, Ogre::String aAddress, int32 aPort) { LOG(INFO) << "Init SRP"; boost::asio::ssl::context sslCtx(boost::asio::ssl::context::tlsv1_server); SSL_CTX* ctx = sslCtx.native_handle(); SSL_CTX_set_info_callback(ctx, SSLInfoCallback); SSL_CTX_SRP_CTX_init(ctx); if (SSL_CTX_set_cipher_list(ctx, "SRP") != 1) { LOG(ERROR) << "Can not set SRP ciphers"; return; } SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); SSL_CTX_set_srp_username_callback(ctx, SSLSRPServerParamCallback); AddUser("test", "test"); LOG(INFO) << "Listening to " << aAddress << ":" << aPort; boost::asio::io_service IOService; boost::asio::ip::tcp::acceptor gate(IOService, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), aPort)); while (true) { SSLStreamPtr sslStream(new SSLStream(IOService, sslCtx)); gate.accept(sslStream->lowest_layer()); boost::thread thrd(boost::bind(ClientConnection, boost::ref(aGame), sslStream)); } }
/* Perform TLS handshake. */ void SSLSocket::handshake(handshake_callback cb, peer_auth_callback authCb) { assert (_state == State::Open); assert (_r.state == Read::State::Off); assert (_w.state == Write::State::Off); _state = State::Handshaking; _h.cb = std::move(cb); _h.authCb = std::move(authCb); if (!isServer()) { /* If this socket was created by the client, the socket has not yet been wrapped as an SSL socket */ sslCtx().initializeSecurity(_fd); } sslCtx().initializeTLS(*this); handshakeContinue(); }