My problem seems to be related to the fact that openssl does not have a continuation style for callbacks such as server name (SNI), but I'm trying to insert it into it.
I want to avoid blocking the workflow when reading SSL greetings clients and avoiding blocking the workflow while I refuse to return the SNI callback while waiting for the ssl server session to end (so that I can re-sign the server certificate).
To asio
bsaed re-sign the SSL proxy using the shell boost::asio::ssl::stream
for openssl.
I use assistants SSL_CTX_set_tlsext_servername_*
to get a callback during SSL negotiation with a client.
For now, make sure I'm using a coroutine and a handshake inside the lambda from boost::asio::spawn
on strand
. I am using a server name callback (suitably wrapped) so that I can block the client from acknowledging while shaking the server, but without blocking the workflow (the routine will be paused.)
boost::asio::spawn(strand_, [=](boost::asio::yield_context yield){
boost::system::error_code ec;
boost::system::error_code ec_server;
sni_callback = [=,&ec](std::string server_name) {
server_->ssl_connection->ssl_socket.async_handshake(boost::asio::ssl::stream_base::client, yield[ec_server]);
};
ssl_connection->ssl_socket.handshake(boost::asio::ssl:stream_base::server, ec);
if (! ec) ec = ec_server;
handler(ec);
});
But I understand that ssl handshake with the client is blocking the worker thread using it.
I tried the asyc handshake with the client:
ssl_connection->ssl_socket.async_handshake(boost::asio::ssl:stream_base::server, yield[ec]);
but the segfaults program is in exit during the SNI handler wrapper.
, , SNI - , ( ), - coroutine, , .
( libstd++ ..) stacktrace:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
seed3_len=-1657747584, seed4=0x23635fe, seed4_len=-1657747600, sec=0x7f82a0035df0 "\321\365M\236\202\177", slen=<optimized out>, out1=0x7f82a0035178 "d\356@",
out2=0x7f82a0038508 "", olen=4247053, seed5_len=0, seed5=0x0) at t1_enc.c:272
.
.
.
.
.
.
, .
SNI , , ssl:: stream .
?
, boost:: ssl , coroutine, , , asio_handler_invoke , . asio_handler_invoke ( -y) .
asio_invoke_handler ?