summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSpencer Jackson <spencer.jackson@mongodb.com>2020-09-08 20:37:41 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-17 15:52:29 +0000
commit32041ff125edcfd74d45b63db4ba19aa9840c62e (patch)
treef1ac1424858b47e85c0acdcf4e1185dd20ae231a /src
parent0541641137ae7b25d61c58b579be4985f43c1472 (diff)
downloadmongo-32041ff125edcfd74d45b63db4ba19aa9840c62e.tar.gz
SERVER-50736 Make OpenSSL explicitly accept SNIs
(cherry picked from commit a5f72d4b37ed92fa72d3a31e0af4266c9ef8d014)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/util/net/ssl_manager_openssl.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/util/net/ssl_manager_openssl.cpp b/src/mongo/util/net/ssl_manager_openssl.cpp
index c31112bac48..c016eb788c8 100644
--- a/src/mongo/util/net/ssl_manager_openssl.cpp
+++ b/src/mongo/util/net/ssl_manager_openssl.cpp
@@ -1190,6 +1190,7 @@ private:
* Callbacks for SSL functions.
*/
static int password_cb(char* buf, int num, int rwflag, void* userdata);
+ static int servername_cb(SSL* s, int* al, void* arg);
static int verify_cb(int ok, X509_STORE_CTX* ctx);
};
@@ -1414,6 +1415,12 @@ int SSLManagerOpenSSL::password_cb(char* buf, int num, int rwflag, void* userdat
return copyCount;
}
+int SSLManagerOpenSSL::servername_cb(SSL* s, int* al, void* arg) {
+ // Unconditionally accept the SNI presented by the client. This will ensure that if the client
+ // later performs session resumption, subsequent connections will still have access to the SNI.
+ return SSL_TLSEXT_ERR_OK;
+}
+
int SSLManagerOpenSSL::verify_cb(int ok, X509_STORE_CTX* ctx) {
return 1; // always succeed; we will catch the error in our get_verify_result() call
}
@@ -1921,6 +1928,13 @@ Status SSLManagerOpenSSL::initSSLContext(SSL_CTX* context,
<< getSSLErrorMessage(ERR_get_error()));
}
+ // We should accept all SNI extensions advertised by clients
+ if (1 != SSL_CTX_set_tlsext_servername_callback(context, &SSLManagerOpenSSL::servername_cb)) {
+ return Status(ErrorCodes::InvalidSSLConfiguration,
+ str::stream() << "Can not set servername callback: "
+ << getSSLErrorMessage(ERR_get_error()));
+ }
+
if (direction == ConnectionDirection::kOutgoing && params.tlsWithholdClientCertificate) {
// Do not send a client certificate if they have been suppressed.