|
|
232633 |
From 9208a7d1a9869a963c29d11def4a31a85eeaeeec Mon Sep 17 00:00:00 2001
|
|
|
232633 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
232633 |
Date: Tue, 14 May 2019 16:58:55 -0400
|
|
|
232633 |
Subject: [PATCH] Ticket 50355 - NSS can change the requested SSL min and max
|
|
|
232633 |
versions
|
|
|
232633 |
|
|
|
232633 |
Description: If we try and set a min and max SSL version in the server,
|
|
|
232633 |
it is actually only a request. After setting the min and
|
|
|
232633 |
max, you need to retrieve the min and max to see what NSS
|
|
|
232633 |
did. Then you have to reset the min and max versions one
|
|
|
232633 |
more time to actually set the valid range. So yes, you do
|
|
|
232633 |
have to do a set() -> get() -> set().
|
|
|
232633 |
|
|
|
232633 |
There also another outstanding issue with NSS where it says
|
|
|
232633 |
the default max SSL version in FIPS mode is 1.3, but in fact
|
|
|
232633 |
it is 1.2. So this patch has a hack fix to workaround that
|
|
|
232633 |
bug. It should be able to be removed soon...
|
|
|
232633 |
|
|
|
232633 |
https://pagure.io/389-ds-base/issue/50355
|
|
|
232633 |
|
|
|
232633 |
Reviewed by: mhonek(Thanks!)
|
|
|
232633 |
---
|
|
|
232633 |
ldap/servers/slapd/ssl.c | 95 ++++++++++++++++++++++++----------------
|
|
|
232633 |
1 file changed, 57 insertions(+), 38 deletions(-)
|
|
|
232633 |
|
|
|
232633 |
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
|
|
|
232633 |
index a7c3ab7b1..2d7bc2bd6 100644
|
|
|
232633 |
--- a/ldap/servers/slapd/ssl.c
|
|
|
232633 |
+++ b/ldap/servers/slapd/ssl.c
|
|
|
232633 |
@@ -41,15 +41,15 @@
|
|
|
232633 |
* Default SSL Version Rule
|
|
|
232633 |
* Old SSL version attributes:
|
|
|
232633 |
* nsSSL3: off -- nsSSL3 == SSL_LIBRARY_VERSION_3_0
|
|
|
232633 |
- * nsTLS1: on -- nsTLS1 == SSL_LIBRARY_VERSION_TLS_1_0 and greater
|
|
|
232633 |
+ * nsTLS1: on -- nsTLS1 == SSL_LIBRARY_VERSION_TLS_1_2 and greater
|
|
|
232633 |
* Note: TLS1.0 is defined in RFC2246, which is close to SSL 3.0.
|
|
|
232633 |
* New SSL version attributes:
|
|
|
232633 |
- * sslVersionMin: TLS1.0
|
|
|
232633 |
+ * sslVersionMin: TLS1.2
|
|
|
232633 |
* sslVersionMax: max ssl version supported by NSS
|
|
|
232633 |
******************************************************************************/
|
|
|
232633 |
|
|
|
232633 |
-#define DEFVERSION "TLS1.0"
|
|
|
232633 |
-#define CURRENT_DEFAULT_SSL_VERSION SSL_LIBRARY_VERSION_TLS_1_0
|
|
|
232633 |
+#define DEFVERSION "TLS1.2"
|
|
|
232633 |
+#define CURRENT_DEFAULT_SSL_VERSION SSL_LIBRARY_VERSION_TLS_1_2
|
|
|
232633 |
|
|
|
232633 |
extern char *slapd_SSL3ciphers;
|
|
|
232633 |
extern symbol_t supported_ciphers[];
|
|
|
232633 |
@@ -435,8 +435,13 @@ getSSLVersionRange(char **min, char **max)
|
|
|
232633 |
return -1;
|
|
|
232633 |
}
|
|
|
232633 |
if (!slapd_ssl_listener_is_initialized()) {
|
|
|
232633 |
+ /*
|
|
|
232633 |
+ * We have not initialized NSS yet, so we will set the default for
|
|
|
232633 |
+ * now. Then it will get adjusted to NSS's default min and max once
|
|
|
232633 |
+ * we complete the security initialization in slapd_ssl_init2()
|
|
|
232633 |
+ */
|
|
|
232633 |
if (min) {
|
|
|
232633 |
- *min = slapi_getSSLVersion_str(LDAP_OPT_X_TLS_PROTOCOL_TLS1_0, NULL, 0);
|
|
|
232633 |
+ *min = slapi_getSSLVersion_str(LDAP_OPT_X_TLS_PROTOCOL_TLS1_2, NULL, 0);
|
|
|
232633 |
}
|
|
|
232633 |
if (max) {
|
|
|
232633 |
*max = slapi_getSSLVersion_str(LDAP_OPT_X_TLS_PROTOCOL_TLS1_2, NULL, 0);
|
|
|
232633 |
@@ -457,7 +462,7 @@ getSSLVersionRangeOL(int *min, int *max)
|
|
|
232633 |
{
|
|
|
232633 |
/* default range values */
|
|
|
232633 |
if (min) {
|
|
|
232633 |
- *min = LDAP_OPT_X_TLS_PROTOCOL_TLS1_0;
|
|
|
232633 |
+ *min = LDAP_OPT_X_TLS_PROTOCOL_TLS1_2;
|
|
|
232633 |
}
|
|
|
232633 |
if (max) {
|
|
|
232633 |
*max = LDAP_OPT_X_TLS_PROTOCOL_TLS1_2;
|
|
|
232633 |
@@ -2099,43 +2104,57 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
|
|
|
232633 |
}
|
|
|
232633 |
}
|
|
|
232633 |
|
|
|
232633 |
- if (NSSVersionMin > 0) {
|
|
|
232633 |
- /* Use new NSS API SSL_VersionRangeSet (NSS3.14 or newer) */
|
|
|
232633 |
- slapdNSSVersions.min = NSSVersionMin;
|
|
|
232633 |
- slapdNSSVersions.max = NSSVersionMax;
|
|
|
232633 |
- restrict_SSLVersionRange();
|
|
|
232633 |
- (void)slapi_getSSLVersion_str(slapdNSSVersions.min, mymin, sizeof(mymin));
|
|
|
232633 |
- (void)slapi_getSSLVersion_str(slapdNSSVersions.max, mymax, sizeof(mymax));
|
|
|
232633 |
- slapi_log_err(SLAPI_LOG_INFO, "Security Initialization",
|
|
|
232633 |
- "slapd_ssl_init2 - Configured SSL version range: min: %s, max: %s\n",
|
|
|
232633 |
- mymin, mymax);
|
|
|
232633 |
+ /* Handle the SSL version range */
|
|
|
232633 |
+ slapdNSSVersions.min = NSSVersionMin;
|
|
|
232633 |
+ slapdNSSVersions.max = NSSVersionMax;
|
|
|
232633 |
+ restrict_SSLVersionRange();
|
|
|
232633 |
+ (void)slapi_getSSLVersion_str(slapdNSSVersions.min, mymin, sizeof(mymin));
|
|
|
232633 |
+ (void)slapi_getSSLVersion_str(slapdNSSVersions.max, mymax, sizeof(mymax));
|
|
|
232633 |
+ slapi_log_err(SLAPI_LOG_INFO, "Security Initialization",
|
|
|
232633 |
+ "slapd_ssl_init2 - Configured SSL version range: min: %s, max: %s\n",
|
|
|
232633 |
+ mymin, mymax);
|
|
|
232633 |
+ sslStatus = SSL_VersionRangeSet(pr_sock, &slapdNSSVersions);
|
|
|
232633 |
+ if (sslStatus != SECSuccess) {
|
|
|
232633 |
+ errorCode = PR_GetError();
|
|
|
232633 |
+ slapd_SSL_error("Security Initialization - "
|
|
|
232633 |
+ "slapd_ssl_init2 - Failed to set SSL range: min: %s, max: %s - error %d (%s)\n",
|
|
|
232633 |
+ mymin, mymax, errorCode, slapd_pr_strerror(errorCode));
|
|
|
232633 |
+ }
|
|
|
232633 |
+ /*
|
|
|
232633 |
+ * Get the version range as NSS might have adjusted our requested range. FIPS mode is
|
|
|
232633 |
+ * pretty picky about this stuff.
|
|
|
232633 |
+ */
|
|
|
232633 |
+ sslStatus = SSL_VersionRangeGet(pr_sock, &slapdNSSVersions);
|
|
|
232633 |
+ if (sslStatus == SECSuccess) {
|
|
|
232633 |
+ if (slapdNSSVersions.max > LDAP_OPT_X_TLS_PROTOCOL_TLS1_2 && slapd_pk11_isFIPS()) {
|
|
|
232633 |
+ /*
|
|
|
232633 |
+ * FIPS & NSS currently only support a max version of TLS1.2
|
|
|
232633 |
+ * (although NSS advertises 1.3 as a max range in FIPS mode),
|
|
|
232633 |
+ * hopefully this code block can be removed soon...
|
|
|
232633 |
+ */
|
|
|
232633 |
+ slapdNSSVersions.max = LDAP_OPT_X_TLS_PROTOCOL_TLS1_2;
|
|
|
232633 |
+ }
|
|
|
232633 |
+ /* Reset request range */
|
|
|
232633 |
sslStatus = SSL_VersionRangeSet(pr_sock, &slapdNSSVersions);
|
|
|
232633 |
if (sslStatus == SECSuccess) {
|
|
|
232633 |
- /* Set the restricted value to the cn=encryption entry */
|
|
|
232633 |
+ (void)slapi_getSSLVersion_str(slapdNSSVersions.min, mymin, sizeof(mymin));
|
|
|
232633 |
+ (void)slapi_getSSLVersion_str(slapdNSSVersions.max, mymax, sizeof(mymax));
|
|
|
232633 |
+ slapi_log_err(SLAPI_LOG_INFO, "Security Initialization",
|
|
|
232633 |
+ "slapd_ssl_init2 - NSS adjusted SSL version range: min: %s, max: %s\n",
|
|
|
232633 |
+ mymin, mymax);
|
|
|
232633 |
} else {
|
|
|
232633 |
+ errorCode = PR_GetError();
|
|
|
232633 |
+ (void)slapi_getSSLVersion_str(slapdNSSVersions.min, mymin, sizeof(mymin));
|
|
|
232633 |
+ (void)slapi_getSSLVersion_str(slapdNSSVersions.max, mymax, sizeof(mymax));
|
|
|
232633 |
slapd_SSL_error("Security Initialization - "
|
|
|
232633 |
- "slapd_ssl_init2 - Failed to set SSL range: min: %s, max: %s\n",
|
|
|
232633 |
- mymin, mymax);
|
|
|
232633 |
+ "slapd_ssl_init2 - Failed to set SSL range: min: %s, max: %s - error %d (%s)\n",
|
|
|
232633 |
+ mymin, mymax, errorCode, slapd_pr_strerror(errorCode));
|
|
|
232633 |
}
|
|
|
232633 |
} else {
|
|
|
232633 |
- /* deprecated code */
|
|
|
232633 |
- sslStatus = SSL_OptionSet(pr_sock, SSL_ENABLE_SSL3, enableSSL3);
|
|
|
232633 |
- if (sslStatus != SECSuccess) {
|
|
|
232633 |
- errorCode = PR_GetError();
|
|
|
232633 |
- slapd_SSL_warn("Failed to %s SSLv3 "
|
|
|
232633 |
- "on the imported socket (" SLAPI_COMPONENT_NAME_NSPR " error %d - %s)",
|
|
|
232633 |
- enableSSL3 ? "enable" : "disable",
|
|
|
232633 |
- errorCode, slapd_pr_strerror(errorCode));
|
|
|
232633 |
- }
|
|
|
232633 |
-
|
|
|
232633 |
- sslStatus = SSL_OptionSet(pr_sock, SSL_ENABLE_TLS, enableTLS1);
|
|
|
232633 |
- if (sslStatus != SECSuccess) {
|
|
|
232633 |
- errorCode = PR_GetError();
|
|
|
232633 |
- slapd_SSL_warn("Failed to %s TLSv1 "
|
|
|
232633 |
- "on the imported socket (" SLAPI_COMPONENT_NAME_NSPR " error %d - %s)",
|
|
|
232633 |
- enableTLS1 ? "enable" : "disable",
|
|
|
232633 |
- errorCode, slapd_pr_strerror(errorCode));
|
|
|
232633 |
- }
|
|
|
232633 |
+ errorCode = PR_GetError();
|
|
|
232633 |
+ slapd_SSL_error("Security Initialization - ",
|
|
|
232633 |
+ "slapd_ssl_init2 - Failed to get SSL range from socket - error %d (%s)\n",
|
|
|
232633 |
+ errorCode, slapd_pr_strerror(errorCode));
|
|
|
232633 |
}
|
|
|
232633 |
|
|
|
232633 |
val = NULL;
|
|
|
232633 |
@@ -2221,7 +2240,7 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
|
|
|
232633 |
* that matters. */
|
|
|
232633 |
|
|
|
232633 |
if (!startTLS)
|
|
|
232633 |
- _ssl_listener_initialized = 1; /* --ugaston */
|
|
|
232633 |
+ _ssl_listener_initialized = 1;
|
|
|
232633 |
|
|
|
232633 |
return 0;
|
|
|
232633 |
}
|
|
|
232633 |
--
|
|
|
232633 |
2.21.0
|
|
|
232633 |
|