diff options
author | Nathan Dorfman <ndorf@rtfm.net> | 2021-07-27 13:34:11 -0600 |
---|---|---|
committer | Nathan Dorfman <ndorf@rtfm.net> | 2021-07-27 13:49:21 -0600 |
commit | bf9605521103f86428155109c7b796ac129ac702 (patch) | |
tree | e2d0cdb17c4b1063e656d2c83468e2c555bfcf57 | |
parent | Merge pull request #7764 (diff) | |
download | monero-bf9605521103f86428155109c7b796ac129ac702.tar.xz |
Make SSL key/cert storage backward-compatible
This is required to build on OpenBSD (which uses LibreSSL). It also allows building against versions of OpenSSL before 1.0.2.
-rw-r--r-- | contrib/epee/src/net_ssl.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/epee/src/net_ssl.cpp b/contrib/epee/src/net_ssl.cpp index 765dadce3..70cd0d0ad 100644 --- a/contrib/epee/src/net_ssl.cpp +++ b/contrib/epee/src/net_ssl.cpp @@ -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*); |