Commit 48380667 authored by Andrew Huang's avatar Andrew Huang Committed by Facebook GitHub Bot

Add the ability to turn on non-DHE resumption for clients in TLS 1.3

Summary:
Add API to allow clients to advertise support for psk_ke (non-DHE) resumption. Unfortunately, OpenSSL has no option to allow servers to support psk_ke resumption.

SSL_OP_ALLOW_NO_DHE_KEX option was added in OpenSSL 1.1.1, so add the appropriate guard.

Reviewed By: mingtaoy

Differential Revision: D24546720

fbshipit-source-id: fd7c5b3a9f4c572876f9b421ee8f74ba7d5e252c
parent 3a1cb2bc
...@@ -778,6 +778,15 @@ void SSLContext::setCiphersuitesOrThrow(const std::string& ciphersuites) { ...@@ -778,6 +778,15 @@ void SSLContext::setCiphersuitesOrThrow(const std::string& ciphersuites) {
throw std::runtime_error("SSL_CTX_set_ciphersuites: " + getErrors()); throw std::runtime_error("SSL_CTX_set_ciphersuites: " + getErrors());
} }
} }
void SSLContext::setAllowNoDheKex(bool flag) {
auto opt = SSL_OP_ALLOW_NO_DHE_KEX;
if (flag) {
SSL_CTX_set_options(ctx_, opt);
} else {
SSL_CTX_clear_options(ctx_, opt);
}
}
#endif // FOLLY_OPENSSL_PREREQ(1, 1, 1) #endif // FOLLY_OPENSSL_PREREQ(1, 1, 1)
std::ostream& operator<<(std::ostream& os, const PasswordCollector& collector) { std::ostream& operator<<(std::ostream& os, const PasswordCollector& collector) {
......
...@@ -567,6 +567,13 @@ class SSLContext { ...@@ -567,6 +567,13 @@ class SSLContext {
* Throws if unsuccessful. * Throws if unsuccessful.
*/ */
void setCiphersuitesOrThrow(const std::string& ciphersuites); void setCiphersuitesOrThrow(const std::string& ciphersuites);
/**
* Enables/disables non-DHE (Ephemeral Diffie-Hellman) PSK key
* exchange for TLS 1.3 resumption. Note that this key exchange
* mode gives up forward secrecy on the resumed session.
*/
void setAllowNoDheKex(bool flag);
#endif #endif
[[deprecated("Use folly::ssl::init")]] static void initializeOpenSSL(); [[deprecated("Use folly::ssl::init")]] static void initializeOpenSSL();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment