Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support OpenSSL 1.1.0 #2151

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/ripple/basics/impl/make_SSLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,21 @@ using rsa_ptr = custom_delete_unique_ptr <RSA>;

static rsa_ptr rsa_generate_key (int n_bits)
{
#if OPENSSL_VERSION_NUMBER >= 0x00908000L
BIGNUM *bn = BN_new();
BN_set_word(bn, RSA_F4);

RSA* rsa = RSA_new();
if (RSA_generate_key_ex(rsa, n_bits, bn, nullptr) != 1)
{
RSA_free(rsa);
rsa = nullptr;
}

BN_free(bn);
#else
RSA* rsa = RSA_generate_key (n_bits, RSA_F4, nullptr, nullptr);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested way to hold these resources: HowardHinnant@720aa29


if (rsa == nullptr)
LogicError ("RSA_generate_key failed");
Expand Down Expand Up @@ -152,6 +166,7 @@ static void ssl_ctx_use_privatekey (SSL_CTX* const ctx, evp_pkey_ptr& key)
LogicError ("SSL_CTX_use_PrivateKey failed");
}

#ifdef SSL_FLAGS_NO_RENEGOTIATE_CIPHERS
static
bool
disallowRenegotiation (SSL const* ssl, bool isNew)
Expand Down Expand Up @@ -211,6 +226,7 @@ info_handler (SSL const* ssl, int event, int)
ssl->s3->flags |= SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS;
}
}
#endif

static
std::string
Expand Down Expand Up @@ -395,7 +411,10 @@ get_context (std::string cipherList)
LogicError ("d2i_DHparams returned nullptr.");

SSL_CTX_set_tmp_dh (c->native_handle (), dh);

#ifdef SSL_FLAGS_NO_RENEGOTIATE_CIPHERS
SSL_CTX_set_info_callback (c->native_handle (), info_handler);
#endif

return c;
}
Expand Down
4 changes: 4 additions & 0 deletions src/ripple/beast/asio/ssl_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ inline
bool
is_short_read(boost::system::error_code const& ec)
{
#ifdef SSL_R_SHORT_READ
return (ec.category() == boost::asio::error::get_ssl_category())
&& (ERR_GET_REASON(ec.value()) == SSL_R_SHORT_READ);
#else
return false;
#endif
}

} // beast
Expand Down