diff options
author | Spencer Jackson <spencer.jackson@mongodb.com> | 2015-03-11 14:09:55 -0400 |
---|---|---|
committer | Spencer Jackson <spencer.jackson@mongodb.com> | 2015-03-13 16:02:07 -0400 |
commit | a5a48528b5349cc9af56b784f4fd583dcfb11e32 (patch) | |
tree | 856d9be6314a477fb0abd209131494e98493ac84 | |
parent | f6debcc8c2884c60a1d694e35089c2950cccb946 (diff) | |
download | mongo-a5a48528b5349cc9af56b784f4fd583dcfb11e32.tar.gz |
SERVER-16073: Allow overrides to OpenSSL ciphers
-rw-r--r-- | src/mongo/util/net/ssl_manager.cpp | 15 | ||||
-rw-r--r-- | src/mongo/util/net/ssl_options.cpp | 9 | ||||
-rw-r--r-- | src/mongo/util/net/ssl_options.h | 1 |
3 files changed, 24 insertions, 1 deletions
diff --git a/src/mongo/util/net/ssl_manager.cpp b/src/mongo/util/net/ssl_manager.cpp index 40682822d1c..ce90e9c29c7 100644 --- a/src/mongo/util/net/ssl_manager.cpp +++ b/src/mongo/util/net/ssl_manager.cpp @@ -134,6 +134,7 @@ namespace mongo { const std::string& clusterpwd, const std::string& cafile = "", const std::string& crlfile = "", + const std::string& cipherConfig = "", bool weakCertificateValidation = false, bool allowInvalidCertificates = false, bool allowInvalidHostnames = false, @@ -144,6 +145,7 @@ namespace mongo { clusterpwd(clusterpwd), cafile(cafile), crlfile(crlfile), + cipherConfig(cipherConfig), weakCertificateValidation(weakCertificateValidation), allowInvalidCertificates(allowInvalidCertificates), allowInvalidHostnames(allowInvalidHostnames), @@ -155,6 +157,7 @@ namespace mongo { std::string clusterpwd; std::string cafile; std::string crlfile; + std::string cipherConfig; bool weakCertificateValidation; bool allowInvalidCertificates; bool allowInvalidHostnames; @@ -293,6 +296,7 @@ namespace mongo { sslGlobalParams.sslClusterPassword, sslGlobalParams.sslCAFile, sslGlobalParams.sslCRLFile, + sslGlobalParams.sslCipherConfig, sslGlobalParams.sslWeakCertificateValidation, sslGlobalParams.sslAllowInvalidCertificates, sslGlobalParams.sslAllowInvalidHostnames, @@ -540,7 +544,16 @@ namespace mongo { // !EXPORT - Disable export ciphers (40/56 bit) // !aNULL - Disable anonymous auth ciphers // @STRENGTH - Sort ciphers based on strength - SSL_CTX_set_cipher_list(*context, "HIGH:!EXPORT:!aNULL@STRENGTH"); + std::string cipherConfig = "HIGH:!EXPORT:!aNULL@STRENGTH"; + + // Allow the cipher configuration string to be overriden by --sslCipherConfig + if (!params.cipherConfig.empty()) { + cipherConfig = params.cipherConfig; + } + + massert(28615, mongoutils::str::stream() << "can't set supported cipher suites: " << + getSSLErrorMessage(ERR_get_error()), + SSL_CTX_set_cipher_list(*context, cipherConfig.c_str())); // If renegotiation is needed, don't return from recv() or send() until it's successful. // Note: this is for blocking sockets only. diff --git a/src/mongo/util/net/ssl_options.cpp b/src/mongo/util/net/ssl_options.cpp index 71d2431f87d..d781dbead3e 100644 --- a/src/mongo/util/net/ssl_options.cpp +++ b/src/mongo/util/net/ssl_options.cpp @@ -52,6 +52,10 @@ namespace mongo { options->addOptionChaining("net.ssl.CRLFile", "sslCRLFile", moe::String, "Certificate Revocation List file for SSL"); + options->addOptionChaining("net.ssl.sslCipherConfig", "sslCipherConfig", moe::String, + "OpenSSL cipher configuration string") + .hidden(); + options->addOptionChaining("net.ssl.weakCertificateValidation", "sslWeakCertificateValidation", moe::Switch, "allow client to connect without " "presenting a certificate"); @@ -170,6 +174,10 @@ namespace mongo { params["net.ssl.CRLFile"].as<std::string>()).generic_string(); } + if (params.count("net.ssl.sslCipherConfig")) { + sslGlobalParams.sslCipherConfig = params["net.ssl.sslCipherConfig"].as<string>(); + } + if (params.count("net.ssl.weakCertificateValidation")) { sslGlobalParams.sslWeakCertificateValidation = true; } @@ -209,6 +217,7 @@ namespace mongo { sslGlobalParams.sslClusterPassword.size() || sslGlobalParams.sslCAFile.size() || sslGlobalParams.sslCRLFile.size() || + sslGlobalParams.sslCipherConfig.size() || sslGlobalParams.sslWeakCertificateValidation || sslGlobalParams.sslFIPSMode) { return Status(ErrorCodes::BadValue, diff --git a/src/mongo/util/net/ssl_options.h b/src/mongo/util/net/ssl_options.h index 7235c64221f..de6c5722229 100644 --- a/src/mongo/util/net/ssl_options.h +++ b/src/mongo/util/net/ssl_options.h @@ -37,6 +37,7 @@ namespace mongo { std::string sslClusterPassword; // --sslInternalKeyPassword std::string sslCAFile; // --sslCAFile std::string sslCRLFile; // --sslCRLFile + std::string sslCipherConfig; // --sslCipherConfig bool sslWeakCertificateValidation; // --sslWeakCertificateValidation bool sslFIPSMode; // --sslFIPSMode bool sslAllowInvalidCertificates; // --sslAllowInvalidCertificates |