summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/util/net/ssl_manager.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/util/net/ssl_manager.cpp b/src/mongo/util/net/ssl_manager.cpp
index e28a1355ebb..2810284e75e 100644
--- a/src/mongo/util/net/ssl_manager.cpp
+++ b/src/mongo/util/net/ssl_manager.cpp
@@ -582,6 +582,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);
};
@@ -946,6 +947,12 @@ int SSLManager::password_cb(char* buf, int num, int rwflag, void* userdata) {
return copied;
}
+int SSLManager::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 SSLManager::verify_cb(int ok, X509_STORE_CTX* ctx) {
return 1; // always succeed; we will catch the error in our get_verify_result() call
}
@@ -1047,6 +1054,13 @@ Status SSLManager::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, &SSLManager::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.