question I have some code setting up an ssl context for boost asio, and when I set the cipher list for http2 ciphers I sometimes get a segfault on exit, when I run the debugger and compile the binary with symbols I can see that the segfault is in pthread key delete in an openssl cleanup function
the following code is simplified to highlight the issue
inline ssl_context& get_ssl_context()
{
// designed to be a singleton ssl context
static ssl_context ctx_(boost::asio::ssl::context::tls_client);
static std::once_flag once_flag;
std::call_once(once_flag, [&] {
ctx_.set_default_verify_paths();
// TODO: Change this to verify peer for deployment
ctx_.set_verify_mode(boost::asio::ssl::verify_none);
ctx_.set_options(
boost::asio::ssl::context::default_workarounds |
boost::asio::ssl::context::no_sslv2 |
boost::asio::ssl::context::no_sslv3 |
boost::asio::ssl::context::no_tlsv1 |
boost::asio::ssl::context::no_tlsv1_1 |
SSL_OP_NO_COMPRESSION
);
// if i comment the following line then the segfault doesn't ever occur on cleanup
int ret = ::SSL_CTX_set_cipher_list(ctx_.native_handle(),
"ECDHE-RSA-CHACHA20-POLY1305"
);
if (ret != 1) {
// If this is zero, OpenSSL rejected the cipher string.
ERR_print_errors_fp(stderr);
}
});
return ctx_;
}
```