Skip to content

Commit

Permalink
Make SSL key/cert storage backward-compatible
Browse files Browse the repository at this point in the history
This is required to build on OpenBSD (which uses LibreSSL). It also allows building against versions of OpenSSL before 1.0.2.
  • Loading branch information
ndorf committed Jul 27, 2021
1 parent de3456e commit bf96055
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion contrib/epee/src/net_ssl.cpp
Expand Up @@ -576,7 +576,8 @@ boost::system::error_code store_ssl_keys(boost::asio::ssl::context& ssl, const b
const auto ctx = ssl.native_handle();
CHECK_AND_ASSERT_MES(ctx, boost::system::error_code(EINVAL, boost::system::system_category()), "Context is null");
CHECK_AND_ASSERT_MES(base.has_filename(), boost::system::error_code(EINVAL, boost::system::system_category()), "Need filename");
if (!(ssl_key = SSL_CTX_get0_privatekey(ctx)) || !(ssl_cert = SSL_CTX_get0_certificate(ctx)))
std::unique_ptr<SSL, decltype(&SSL_free)> dflt_SSL(SSL_new(ctx), SSL_free);
if (!dflt_SSL || !(ssl_key = SSL_get_privatekey(dflt_SSL.get())) || !(ssl_cert = SSL_get_certificate(dflt_SSL.get())))
return {EINVAL, boost::system::system_category()};

using file_closer = int(std::FILE*);
Expand Down

0 comments on commit bf96055

Please sign in to comment.