Blame SOURCES/0086-Ticket-49726-DS-only-accepts-RSA-and-Fortezza-cipher.patch

b663b9
From b6894f921a0635dba97a0745ce75917284e5e5ff Mon Sep 17 00:00:00 2001
b663b9
From: Mark Reynolds <mreynolds@redhat.com>
b663b9
Date: Sun, 27 May 2018 10:48:55 -0400
b663b9
Subject: [PATCH] Ticket 49726 - DS only accepts RSA and Fortezza cipher
b663b9
 families
b663b9
b663b9
Bug Description:  Currently DS only accepts fortezza and RSA cipher families.
b663b9
                  This prevents things like ECC certificates from being used.
b663b9
b663b9
Fix Description:  Instead of hardcoding the cipher families, just grab the
b663b9
                  current type and use it.
b663b9
b663b9
                  Also cleaned up code: removed unncessary "ifdefs", and switched
b663b9
                  for loops to use size_t.
b663b9
b663b9
https://pagure.io/389-ds-base/issue/49726
b663b9
b663b9
Reviewed by: ?
b663b9
b663b9
(cherry picked from commit 27a16a068887e5b9fcab3b4507d58a18e6f1d1ec)
b663b9
---
b663b9
 ldap/servers/slapd/ssl.c | 136 ++++++---------------------------------
b663b9
 1 file changed, 20 insertions(+), 116 deletions(-)
b663b9
b663b9
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
b663b9
index 36b09fd16..b8eba2da4 100644
b663b9
--- a/ldap/servers/slapd/ssl.c
b663b9
+++ b/ldap/servers/slapd/ssl.c
b663b9
@@ -31,28 +31,11 @@
b663b9
 #include "fe.h"
b663b9
 #include "certdb.h"
b663b9
 
b663b9
-#if !defined(USE_OPENLDAP)
b663b9
-#include "ldap_ssl.h"
b663b9
-#endif
b663b9
-
b663b9
 /* For IRIX... */
b663b9
 #ifndef MAXPATHLEN
b663b9
 #define MAXPATHLEN 1024
b663b9
 #endif
b663b9
 
b663b9
-#if NSS_VMAJOR * 100 + NSS_VMINOR >= 315
b663b9
-/* TLS1.2 is defined in RFC5246. */
b663b9
-#define NSS_TLS12 1
b663b9
-#elif NSS_VMAJOR * 100 + NSS_VMINOR >= 314
b663b9
-/* TLS1.1 is defined in RFC4346. */
b663b9
-#define NSS_TLS11 1
b663b9
-#else
b663b9
-#define NSS_TLS10 1
b663b9
-#endif
b663b9
-
b663b9
-#if NSS_VMAJOR * 100 + NSS_VMINOR >= 320
b663b9
-#define HAVE_NSS_DHE 1
b663b9
-#endif
b663b9
 
b663b9
 /******************************************************************************
b663b9
  * Default SSL Version Rule
b663b9
@@ -70,10 +53,9 @@
b663b9
 
b663b9
 extern char *slapd_SSL3ciphers;
b663b9
 extern symbol_t supported_ciphers[];
b663b9
-#if !defined(NSS_TLS10) /* NSS_TLS11 or newer */
b663b9
 static SSLVersionRange enabledNSSVersions;
b663b9
 static SSLVersionRange slapdNSSVersions;
b663b9
-#endif
b663b9
+
b663b9
 
b663b9
 /* dongle_file_name is set in slapd_nss_init when we set the path for the
b663b9
    key, cert, and secmod files - the dongle file must be in the same directory
b663b9
@@ -109,12 +91,10 @@ static char *configDN = "cn=encryption,cn=config";
b663b9
 #define CIPHER_SET_DEFAULTWEAKCIPHER 0x10  /* allowWeakCipher is not set in cn=encryption */
b663b9
 #define CIPHER_SET_ALLOWWEAKCIPHER 0x20    /* allowWeakCipher is on */
b663b9
 #define CIPHER_SET_DISALLOWWEAKCIPHER 0x40 /* allowWeakCipher is off */
b663b9
-
b663b9
-#ifdef HAVE_NSS_DHE
b663b9
 #define CIPHER_SET_DEFAULTWEAKDHPARAM 0x100  /* allowWeakDhParam is not set in cn=encryption */
b663b9
 #define CIPHER_SET_ALLOWWEAKDHPARAM 0x200    /* allowWeakDhParam is on */
b663b9
 #define CIPHER_SET_DISALLOWWEAKDHPARAM 0x400 /* allowWeakDhParam is off */
b663b9
-#endif
b663b9
+
b663b9
 
b663b9
 #define CIPHER_SET_ISDEFAULT(flag) \
b663b9
     (((flag)&CIPHER_SET_DEFAULT) ? PR_TRUE : PR_FALSE)
b663b9
@@ -145,10 +125,7 @@ static char *configDN = "cn=encryption,cn=config";
b663b9
 #define CIPHER_IS_WEAK 0x4
b663b9
 #define CIPHER_IS_DEPRECATED 0x8
b663b9
 
b663b9
-#ifdef HAVE_NSS_DHE
b663b9
 static int allowweakdhparam = CIPHER_SET_DEFAULTWEAKDHPARAM;
b663b9
-#endif
b663b9
-
b663b9
 
b663b9
 static char **cipher_names = NULL;
b663b9
 static char **enabled_cipher_names = NULL;
b663b9
@@ -225,12 +202,10 @@ static lookup_cipher _lookup_cipher[] = {
b663b9
     /*{"tls_dhe_dss_1024_des_sha",          ""}, */
b663b9
     {"tls_dhe_dss_1024_rc4_sha", "TLS_RSA_EXPORT1024_WITH_RC4_56_SHA"},
b663b9
     {"tls_dhe_dss_rc4_128_sha", "TLS_DHE_DSS_WITH_RC4_128_SHA"},
b663b9
-#if defined(NSS_TLS12)
b663b9
     /* New in NSS 3.15 */
b663b9
     {"tls_rsa_aes_128_gcm_sha", "TLS_RSA_WITH_AES_128_GCM_SHA256"},
b663b9
     {"tls_dhe_rsa_aes_128_gcm_sha", "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"},
b663b9
     {"tls_dhe_dss_aes_128_gcm_sha", NULL}, /* not available */
b663b9
-#endif
b663b9
     {NULL, NULL}};
b663b9
 
b663b9
 /* E.g., "SSL3", "TLS1.2", "Unknown SSL version: 0x0" */
b663b9
@@ -317,7 +292,6 @@ getSupportedCiphers(void)
b663b9
     SSLCipherSuiteInfo info;
b663b9
     char *sep = "::";
b663b9
     int number_of_ciphers = SSL_NumImplementedCiphers;
b663b9
-    int i;
b663b9
     int idx = 0;
b663b9
     PRBool isFIPS = slapd_pk11_isFIPS();
b663b9
 
b663b9
@@ -325,7 +299,7 @@ getSupportedCiphers(void)
b663b9
 
b663b9
     if ((cipher_names == NULL) && (_conf_ciphers)) {
b663b9
         cipher_names = (char **)slapi_ch_calloc((number_of_ciphers + 1), sizeof(char *));
b663b9
-        for (i = 0; _conf_ciphers[i].name != NULL; i++) {
b663b9
+        for (size_t i = 0; _conf_ciphers[i].name != NULL; i++) {
b663b9
             SSL_GetCipherSuiteInfo((PRUint16)_conf_ciphers[i].num, &info, sizeof(info));
b663b9
             /* only support FIPS approved ciphers in FIPS mode */
b663b9
             if (!isFIPS || info.isFIPS) {
b663b9
@@ -341,7 +315,6 @@ getSupportedCiphers(void)
b663b9
     return cipher_names;
b663b9
 }
b663b9
 
b663b9
-#ifdef HAVE_NSS_DHE
b663b9
 int
b663b9
 get_allow_weak_dh_param(Slapi_Entry *e)
b663b9
 {
b663b9
@@ -365,7 +338,6 @@ get_allow_weak_dh_param(Slapi_Entry *e)
b663b9
     slapi_ch_free((void **)&val;;
b663b9
     return allow;
b663b9
 }
b663b9
-#endif
b663b9
 
b663b9
 
b663b9
 char **
b663b9
@@ -374,7 +346,6 @@ getEnabledCiphers(void)
b663b9
     SSLCipherSuiteInfo info;
b663b9
     char *sep = "::";
b663b9
     int number_of_ciphers = 0;
b663b9
-    int x;
b663b9
     int idx = 0;
b663b9
     PRBool enabled;
b663b9
 
b663b9
@@ -383,14 +354,14 @@ getEnabledCiphers(void)
b663b9
         return NULL;
b663b9
     }
b663b9
     if ((enabled_cipher_names == NULL) && _conf_ciphers) {
b663b9
-        for (x = 0; _conf_ciphers[x].name; x++) {
b663b9
+        for (size_t x = 0; _conf_ciphers[x].name; x++) {
b663b9
             SSL_CipherPrefGetDefault(_conf_ciphers[x].num, &enabled);
b663b9
             if (enabled) {
b663b9
                 number_of_ciphers++;
b663b9
             }
b663b9
         }
b663b9
         enabled_cipher_names = (char **)slapi_ch_calloc((number_of_ciphers + 1), sizeof(char *));
b663b9
-        for (x = 0; _conf_ciphers[x].name; x++) {
b663b9
+        for (size_t x = 0; _conf_ciphers[x].name; x++) {
b663b9
             SSL_CipherPrefGetDefault(_conf_ciphers[x].num, &enabled);
b663b9
             if (enabled) {
b663b9
                 SSL_GetCipherSuiteInfo((PRUint16)_conf_ciphers[x].num, &info, sizeof(info));
b663b9
@@ -472,9 +443,6 @@ getSSLVersionRange(char **min, char **max)
b663b9
         }
b663b9
         return -1;
b663b9
     }
b663b9
-#if defined(NSS_TLS10)
b663b9
-    return -1; /* not supported */
b663b9
-#else          /* NSS_TLS11 or newer */
b663b9
     if (min) {
b663b9
         *min = slapi_getSSLVersion_str(slapdNSSVersions.min, NULL, 0);
b663b9
     }
b663b9
@@ -482,10 +450,8 @@ getSSLVersionRange(char **min, char **max)
b663b9
         *max = slapi_getSSLVersion_str(slapdNSSVersions.max, NULL, 0);
b663b9
     }
b663b9
     return 0;
b663b9
-#endif
b663b9
 }
b663b9
 
b663b9
-#if defined(USE_OPENLDAP)
b663b9
 void
b663b9
 getSSLVersionRangeOL(int *min, int *max)
b663b9
 {
b663b9
@@ -499,10 +465,7 @@ getSSLVersionRangeOL(int *min, int *max)
b663b9
     if (!slapd_ssl_listener_is_initialized()) {
b663b9
         return;
b663b9
     }
b663b9
-#if defined(NSS_TLS10)
b663b9
-    *max = LDAP_OPT_X_TLS_PROTOCOL_TLS1_0;
b663b9
-    return;
b663b9
-#else /* NSS_TLS11 or newer */
b663b9
+
b663b9
     if (min) {
b663b9
         switch (slapdNSSVersions.min) {
b663b9
         case SSL_LIBRARY_VERSION_3_0:
b663b9
@@ -550,14 +513,11 @@ getSSLVersionRangeOL(int *min, int *max)
b663b9
         }
b663b9
     }
b663b9
     return;
b663b9
-#endif
b663b9
 }
b663b9
-#endif /* USE_OPENLDAP */
b663b9
 
b663b9
 static void
b663b9
 _conf_init_ciphers(void)
b663b9
 {
b663b9
-    int x;
b663b9
     SECStatus rc;
b663b9
     SSLCipherSuiteInfo info;
b663b9
     const PRUint16 *implementedCiphers = SSL_GetImplementedCiphers();
b663b9
@@ -568,7 +528,7 @@ _conf_init_ciphers(void)
b663b9
     }
b663b9
     _conf_ciphers = (cipherstruct *)slapi_ch_calloc(SSL_NumImplementedCiphers + 1, sizeof(cipherstruct));
b663b9
 
b663b9
-    for (x = 0; implementedCiphers && (x < SSL_NumImplementedCiphers); x++) {
b663b9
+    for (size_t x = 0; implementedCiphers && (x < SSL_NumImplementedCiphers); x++) {
b663b9
         rc = SSL_GetCipherSuiteInfo(implementedCiphers[x], &info, sizeof info);
b663b9
         if (SECFailure == rc) {
b663b9
             slapi_log_err(SLAPI_LOG_ERR, "Security Initialization",
b663b9
@@ -598,7 +558,6 @@ _conf_init_ciphers(void)
b663b9
 static void
b663b9
 _conf_setallciphers(int flag, char ***suplist, char ***unsuplist)
b663b9
 {
b663b9
-    int x;
b663b9
     SECStatus rc;
b663b9
     PRBool setdefault = CIPHER_SET_ISDEFAULT(flag);
b663b9
     PRBool enabled = CIPHER_SET_ISALL(flag);
b663b9
@@ -608,7 +567,7 @@ _conf_setallciphers(int flag, char ***suplist, char ***unsuplist)
b663b9
 
b663b9
     _conf_init_ciphers();
b663b9
 
b663b9
-    for (x = 0; implementedCiphers && (x < SSL_NumImplementedCiphers); x++) {
b663b9
+    for (size_t x = 0; implementedCiphers && (x < SSL_NumImplementedCiphers); x++) {
b663b9
         if (_conf_ciphers[x].flags & CIPHER_IS_DEFAULT) {
b663b9
             /* certainly, not the first time. */
b663b9
             setme = PR_TRUE;
b663b9
@@ -663,11 +622,10 @@ charray2str(char **ary, const char *delim)
b663b9
 void
b663b9
 _conf_dumpciphers(void)
b663b9
 {
b663b9
-    int x;
b663b9
     PRBool enabled;
b663b9
     /* {"SSL3","rc4", SSL_EN_RC4_128_WITH_MD5}, */
b663b9
     slapd_SSL_info("Configured NSS Ciphers");
b663b9
-    for (x = 0; _conf_ciphers[x].name; x++) {
b663b9
+    for (size_t x = 0; _conf_ciphers[x].name; x++) {
b663b9
         SSL_CipherPrefGetDefault(_conf_ciphers[x].num, &enabled);
b663b9
         if (enabled) {
b663b9
             slapd_SSL_info("\t%s: enabled%s%s%s", _conf_ciphers[x].name,
b663b9
@@ -687,7 +645,8 @@ char *
b663b9
 _conf_setciphers(char *setciphers, int flags)
b663b9
 {
b663b9
     char *t, err[MAGNUS_ERROR_LEN];
b663b9
-    int x, i, active;
b663b9
+    int active;
b663b9
+    size_t x = 0;
b663b9
     char *raw = setciphers;
b663b9
     char **suplist = NULL;
b663b9
     char **unsuplist = NULL;
b663b9
@@ -772,7 +731,7 @@ _conf_setciphers(char *setciphers, int flags)
b663b9
                 }
b663b9
             }
b663b9
             if (lookup) { /* lookup with old cipher name and get NSS cipherSuiteName */
b663b9
-                for (i = 0; _lookup_cipher[i].alias; i++) {
b663b9
+                for (size_t i = 0; _lookup_cipher[i].alias; i++) {
b663b9
                     if (!PL_strcasecmp(setciphers, _lookup_cipher[i].alias)) {
b663b9
                         if (enabled && !_lookup_cipher[i].name[0]) {
b663b9
                             slapd_SSL_warn("Cipher suite %s is not available in NSS %d.%d.  Ignoring %s",
b663b9
@@ -915,9 +874,8 @@ getChildren(char *dn)
b663b9
         slapi_pblock_get(new_pb, SLAPI_PLUGIN_INTOP_RESULT, &search_result);
b663b9
         slapi_pblock_get(new_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &e);
b663b9
         if (e != NULL) {
b663b9
-            int i;
b663b9
             list = (char **)slapi_ch_malloc(sizeof(*list) * (nEntries + 1));
b663b9
-            for (i = 0; e[i] != NULL; i++) {
b663b9
+            for (size_t i = 0; e[i] != NULL; i++) {
b663b9
                 list[i] = slapi_ch_strdup(slapi_entry_get_dn(e[i]));
b663b9
             }
b663b9
             list[nEntries] = NULL;
b663b9
@@ -935,8 +893,7 @@ static void
b663b9
 freeChildren(char **list)
b663b9
 {
b663b9
     if (list != NULL) {
b663b9
-        int i;
b663b9
-        for (i = 0; list[i] != NULL; i++) {
b663b9
+        for (size_t i = 0; list[i] != NULL; i++) {
b663b9
             slapi_ch_free((void **)(&list[i]));
b663b9
         }
b663b9
         slapi_ch_free((void **)(&list));
b663b9
@@ -1017,7 +974,6 @@ warn_if_no_key_file(const char *dir, int no_log)
b663b9
     return ret;
b663b9
 }
b663b9
 
b663b9
-#if !defined(NSS_TLS10) /* NSS_TLS11 or newer */
b663b9
 /*
b663b9
  * If non NULL buf and positive bufsize is given,
b663b9
  * the memory is used to store the version string.
b663b9
@@ -1183,7 +1139,6 @@ restrict_SSLVersionRange(void)
b663b9
         }
b663b9
     }
b663b9
 }
b663b9
-#endif
b663b9
 
b663b9
 /*
b663b9
  * slapd_nss_init() is always called from main(), even if we do not
b663b9
@@ -1206,7 +1161,6 @@ slapd_nss_init(int init_ssl __attribute__((unused)), int config_available __attr
b663b9
     int create_certdb = 0;
b663b9
     PRUint32 nssFlags = 0;
b663b9
     char *certdir;
b663b9
-#if !defined(NSS_TLS10) /* NSS_TLS11 or newer */
b663b9
     char emin[VERSION_STR_LENGTH], emax[VERSION_STR_LENGTH];
b663b9
     /* Get the range of the supported SSL version */
b663b9
     SSL_VersionRangeGetSupported(ssl_variant_stream, &enabledNSSVersions);
b663b9
@@ -1216,7 +1170,6 @@ slapd_nss_init(int init_ssl __attribute__((unused)), int config_available __attr
b663b9
     slapi_log_err(SLAPI_LOG_CONFIG, "Security Initialization",
b663b9
                   "slapd_nss_init - Supported range by NSS: min: %s, max: %s\n",
b663b9
                   emin, emax);
b663b9
-#endif
b663b9
 
b663b9
     /* set in slapd_bootstrap_config,
b663b9
        thus certdir is available even if config_available is false */
b663b9
@@ -1385,9 +1338,7 @@ slapd_ssl_init()
b663b9
     char *val = NULL;
b663b9
     PK11SlotInfo *slot;
b663b9
     Slapi_Entry *entry = NULL;
b663b9
-#ifdef HAVE_NSS_DHE
b663b9
     SECStatus rv = SECFailure;
b663b9
-#endif
b663b9
 
b663b9
     /* Get general information */
b663b9
 
b663b9
@@ -1396,7 +1347,6 @@ slapd_ssl_init()
b663b9
     val = slapi_entry_attr_get_charptr(entry, "nssslSessionTimeout");
b663b9
     ciphers = slapi_entry_attr_get_charptr(entry, "nsssl3ciphers");
b663b9
 
b663b9
-#ifdef HAVE_NSS_DHE
b663b9
     allowweakdhparam = get_allow_weak_dh_param(entry);
b663b9
     if (allowweakdhparam & CIPHER_SET_ALLOWWEAKDHPARAM) {
b663b9
         slapd_SSL_warn("notice, generating new WEAK DH param");
b663b9
@@ -1405,7 +1355,6 @@ slapd_ssl_init()
b663b9
             slapd_SSL_error("Warning, unable to generate weak dh parameters");
b663b9
         }
b663b9
     }
b663b9
-#endif
b663b9
 
b663b9
     /* We are currently using the value of sslSessionTimeout
b663b9
        for ssl3SessionTimeout, see SSL_ConfigServerSessionIDCache() */
b663b9
@@ -1527,7 +1476,6 @@ slapd_ssl_init()
b663b9
     return 0;
b663b9
 }
b663b9
 
b663b9
-#if !defined(NSS_TLS10) /* NSS_TLS11 or newer */
b663b9
 /*
b663b9
  * val:   sslVersionMin/Max value set in cn=encription,cn=config (INPUT)
b663b9
  * rval:  Corresponding value to set SSLVersionRange (OUTPUT)
b663b9
@@ -1541,7 +1489,7 @@ static int
b663b9
 set_NSS_version(char *val, PRUint16 *rval, int ismin)
b663b9
 {
b663b9
     char *vp, *endp;
b663b9
-    int vnum;
b663b9
+    int64_t vnum;
b663b9
     char emin[VERSION_STR_LENGTH], emax[VERSION_STR_LENGTH];
b663b9
 
b663b9
     if (NULL == rval) {
b663b9
@@ -1662,7 +1610,6 @@ set_NSS_version(char *val, PRUint16 *rval, int ismin)
b663b9
                 }
b663b9
             }
b663b9
         } else if (tlsv < 1.3) { /* TLS1.2 */
b663b9
-#if defined(NSS_TLS12)
b663b9
             if (ismin) {
b663b9
                 if (enabledNSSVersions.min > SSL_LIBRARY_VERSION_TLS_1_2) {
b663b9
                     slapd_SSL_warn("The value of sslVersionMin "
b663b9
@@ -1685,7 +1632,6 @@ set_NSS_version(char *val, PRUint16 *rval, int ismin)
b663b9
                     (*rval) = SSL_LIBRARY_VERSION_TLS_1_2;
b663b9
                 }
b663b9
             }
b663b9
-#endif
b663b9
         } else { /* Specified TLS is newer than supported */
b663b9
             if (ismin) {
b663b9
                 slapd_SSL_warn("The value of sslVersionMin "
b663b9
@@ -1720,7 +1666,6 @@ set_NSS_version(char *val, PRUint16 *rval, int ismin)
b663b9
 #undef SSLLEN
b663b9
 #undef TLSSTR
b663b9
 #undef TLSLEN
b663b9
-#endif
b663b9
 
b663b9
 int
b663b9
 slapd_ssl_init2(PRFileDesc **fd, int startTLS)
b663b9
@@ -1740,12 +1685,10 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
b663b9
     char *tmpDir;
b663b9
     Slapi_Entry *e = NULL;
b663b9
     PRBool fipsMode = PR_FALSE;
b663b9
-#if !defined(NSS_TLS10) /* NSS_TLS11 or newer */
b663b9
     PRUint16 NSSVersionMin = enabledNSSVersions.min;
b663b9
     PRUint16 NSSVersionMax = enabledNSSVersions.max;
b663b9
     char mymin[VERSION_STR_LENGTH], mymax[VERSION_STR_LENGTH];
b663b9
     char newmax[VERSION_STR_LENGTH];
b663b9
-#endif
b663b9
     char cipher_string[1024];
b663b9
     int allowweakcipher = CIPHER_SET_DEFAULTWEAKCIPHER;
b663b9
     int_fast16_t renegotiation = (int_fast16_t)SSL_RENEGOTIATE_REQUIRES_XTN;
b663b9
@@ -1964,15 +1907,13 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
b663b9
                 }
b663b9
 
b663b9
                 if (SECSuccess == rv) {
b663b9
+                    SSLKEAType certKEA;
b663b9
 
b663b9
-#ifdef HAVE_NSS_DHE
b663b9
-                    /* Step If we want weak dh params, flag it on the socket now! */
b663b9
-
b663b9
+                    /* If we want weak dh params, flag it on the socket now! */
b663b9
                     rv = SSL_OptionSet(*fd, SSL_ENABLE_SERVER_DHE, PR_TRUE);
b663b9
                     if (rv != SECSuccess) {
b663b9
                         slapd_SSL_warn("Warning, unable to start DHE");
b663b9
                     }
b663b9
-
b663b9
                     if (allowweakdhparam & CIPHER_SET_ALLOWWEAKDHPARAM) {
b663b9
                         slapd_SSL_warn("notice, allowing weak parameters on socket.");
b663b9
                         rv = SSL_EnableWeakDHEPrimeGroup(*fd, PR_TRUE);
b663b9
@@ -1980,13 +1921,9 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
b663b9
                             slapd_SSL_warn("Warning, unable to allow weak DH params on socket.");
b663b9
                         }
b663b9
                     }
b663b9
-#endif
b663b9
 
b663b9
-                    if (slapd_pk11_fortezzaHasKEA(cert) == PR_TRUE) {
b663b9
-                        rv = SSL_ConfigSecureServer(*fd, cert, key, kt_fortezza);
b663b9
-                    } else {
b663b9
-                        rv = SSL_ConfigSecureServer(*fd, cert, key, kt_rsa);
b663b9
-                    }
b663b9
+                    certKEA = NSS_FindCertKEAType(cert);
b663b9
+                    rv = SSL_ConfigSecureServer(*fd, cert, key, certKEA);
b663b9
                     if (SECSuccess != rv) {
b663b9
                         errorCode = PR_GetError();
b663b9
                         slapd_SSL_warn("ConfigSecureServer: "
b663b9
@@ -2140,7 +2077,6 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
b663b9
             enableTLS1 = PR_TRUE; /* If available, enable TLS1 */
b663b9
         }
b663b9
         slapi_ch_free_string(&val;;
b663b9
-#if !defined(NSS_TLS10) /* NSS_TLS11 or newer */
b663b9
         val = slapi_entry_attr_get_charptr(e, "sslVersionMin");
b663b9
         if (val) {
b663b9
             (void)set_NSS_version(val, &NSSVersionMin, 1);
b663b9
@@ -2161,9 +2097,8 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
b663b9
                            mymax, newmax);
b663b9
             NSSVersionMax = enabledNSSVersions.max;
b663b9
         }
b663b9
-#endif
b663b9
     }
b663b9
-#if !defined(NSS_TLS10) /* NSS_TLS11 or newer */
b663b9
+
b663b9
     if (NSSVersionMin > 0) {
b663b9
         /* Use new NSS API SSL_VersionRangeSet (NSS3.14 or newer) */
b663b9
         slapdNSSVersions.min = NSSVersionMin;
b663b9
@@ -2183,7 +2118,6 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
b663b9
                             mymin, mymax);
b663b9
         }
b663b9
     } else {
b663b9
-#endif
b663b9
         /* deprecated code */
b663b9
         sslStatus = SSL_OptionSet(pr_sock, SSL_ENABLE_SSL3, enableSSL3);
b663b9
         if (sslStatus != SECSuccess) {
b663b9
@@ -2202,9 +2136,7 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
b663b9
                            enableTLS1 ? "enable" : "disable",
b663b9
                            errorCode, slapd_pr_strerror(errorCode));
b663b9
         }
b663b9
-#if !defined(NSS_TLS10) /* NSS_TLS11 or newer */
b663b9
     }
b663b9
-#endif
b663b9
 
b663b9
     val = NULL;
b663b9
     if (e != NULL) {
b663b9
@@ -2382,12 +2314,8 @@ slapd_SSL_client_auth(LDAP *ld)
b663b9
                              */
b663b9
                             token = slapi_ch_strdup(internalTokenName);
b663b9
                         }
b663b9
-#if defined(USE_OPENLDAP)
b663b9
                         /* openldap needs tokenname:certnick */
b663b9
                         PR_snprintf(cert_name, sizeof(cert_name), "%s:%s", token, personality);
b663b9
-#else
b663b9
-                        PL_strncpyz(cert_name, personality, sizeof(cert_name));
b663b9
-#endif
b663b9
                         slapi_ch_free_string(&ssltoken);
b663b9
                     } else {
b663b9
                         /* external PKCS #11 token - attach token name */
b663b9
@@ -2461,7 +2389,6 @@ slapd_SSL_client_auth(LDAP *ld)
b663b9
                            "(no password). (" SLAPI_COMPONENT_NAME_NSPR " error %d - %s)",
b663b9
                            errorCode, slapd_pr_strerror(errorCode));
b663b9
         } else {
b663b9
-#if defined(USE_OPENLDAP)
b663b9
             if (slapi_client_uses_non_nss(ld)  && config_get_extract_pem()) {
b663b9
                 char *certdir = config_get_certdir();
b663b9
                 char *keyfile = NULL;
b663b9
@@ -2532,29 +2459,6 @@ slapd_SSL_client_auth(LDAP *ld)
b663b9
                                    cert_name);
b663b9
                 }
b663b9
             }
b663b9
-/*
b663b9
-             * not sure what else needs to be done for client auth - don't
b663b9
-             * currently have a way to pass in the password to use to unlock
b663b9
-             * the keydb - nor a way to disable caching
b663b9
-             */
b663b9
-#else /* !USE_OPENLDAP */
b663b9
-            rc = ldapssl_enable_clientauth(ld, SERVER_KEY_NAME, pw, cert_name);
b663b9
-            if (rc != 0) {
b663b9
-                errorCode = PR_GetError();
b663b9
-                slapd_SSL_error("ldapssl_enable_clientauth(%s, %s) %i (" SLAPI_COMPONENT_NAME_NSPR " error %d - %s)",
b663b9
-                                SERVER_KEY_NAME, cert_name, rc,
b663b9
-                                errorCode, slapd_pr_strerror(errorCode));
b663b9
-            } else {
b663b9
-                /*
b663b9
-                 * We cannot allow NSS to cache outgoing client auth connections -
b663b9
-                 * each client auth connection must have it's own non-shared SSL
b663b9
-                 * connection to the peer so that it will go through the
b663b9
-                 * entire handshake protocol every time including the use of its
b663b9
-                 * own unique client cert - see bug 605457
b663b9
-                 */
b663b9
-                ldapssl_set_option(ld, SSL_NO_CACHE, PR_TRUE);
b663b9
-            }
b663b9
-#endif
b663b9
         }
b663b9
     }
b663b9
 
b663b9
-- 
b663b9
2.17.0
b663b9