|
|
@@ -49,6 +49,10 @@
|
|
|
#define NSS_TLS10 1
|
|
|
#endif
|
|
|
|
|
|
+#if NSS_VMAJOR * 100 + NSS_VMINOR >= 320
|
|
|
+#define HAVE_NSS_DHE 1
|
|
|
+#endif
|
|
|
+
|
|
|
/******************************************************************************
|
|
|
* Default SSL Version Rule
|
|
|
* Old SSL version attributes:
|
|
|
@@ -87,6 +91,7 @@ static int stimeout;
|
|
|
static char *ciphers = NULL;
|
|
|
static char * configDN = "cn=encryption,cn=config";
|
|
|
|
|
|
+
|
|
|
/* Copied from libadmin/libadmin.h public/nsapi.h */
|
|
|
#define SERVER_KEY_NAME "Server-Key"
|
|
|
#define MAGNUS_ERROR_LEN 1024
|
|
|
@@ -103,6 +108,12 @@ static char * configDN = "cn=encryption,cn=config";
|
|
|
#define CIPHER_SET_ALLOWWEAKCIPHER 0x20 /* allowWeakCipher is on */
|
|
|
#define CIPHER_SET_DISALLOWWEAKCIPHER 0x40 /* allowWeakCipher is off */
|
|
|
|
|
|
+#ifdef HAVE_NSS_DHE
|
|
|
+#define CIPHER_SET_DEFAULTWEAKDHPARAM 0x100 /* allowWeakDhParam is not set in cn=encryption */
|
|
|
+#define CIPHER_SET_ALLOWWEAKDHPARAM 0x200 /* allowWeakDhParam is on */
|
|
|
+#define CIPHER_SET_DISALLOWWEAKDHPARAM 0x400 /* allowWeakDhParam is off */
|
|
|
+#endif
|
|
|
+
|
|
|
#define CIPHER_SET_ISDEFAULT(flag) \
|
|
|
(((flag)&CIPHER_SET_DEFAULT) ? PR_TRUE : PR_FALSE)
|
|
|
#define CIPHER_SET_ISALL(flag) \
|
|
|
@@ -114,6 +125,7 @@ static char * configDN = "cn=encryption,cn=config";
|
|
|
(((flag)&CIPHER_SET_ALLOWWEAKCIPHER) ? PR_TRUE : PR_FALSE)
|
|
|
#define ALLOWWEAK_ISOFF(flag) \
|
|
|
(((flag)&CIPHER_SET_DISALLOWWEAKCIPHER) ? PR_TRUE : PR_FALSE)
|
|
|
+
|
|
|
/*
|
|
|
* If ISALL or ISDEFAULT, allowWeakCipher is true only if CIPHER_SET_ALLOWWEAKCIPHER.
|
|
|
* Otherwise (user specified cipher list), allowWeakCipher is true
|
|
|
@@ -132,6 +144,12 @@ static char * configDN = "cn=encryption,cn=config";
|
|
|
#define CIPHER_MUST_BE_DISABLED 0x2
|
|
|
#define CIPHER_IS_WEAK 0x4
|
|
|
#define CIPHER_IS_DEPRECATED 0x8
|
|
|
+
|
|
|
+#ifdef HAVE_NSS_DHE
|
|
|
+static int allowweakdhparam = CIPHER_SET_DEFAULTWEAKDHPARAM;
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
static char **cipher_names = NULL;
|
|
|
static char **enabled_cipher_names = NULL;
|
|
|
typedef struct {
|
|
|
@@ -302,6 +320,33 @@ getSupportedCiphers()
|
|
|
return cipher_names;
|
|
|
}
|
|
|
|
|
|
+#ifdef HAVE_NSS_DHE
|
|
|
+int
|
|
|
+get_allow_weak_dh_param(Slapi_Entry *e)
|
|
|
+{
|
|
|
+ /* Check if the user wants weak params */
|
|
|
+ int allow = CIPHER_SET_DEFAULTWEAKDHPARAM;
|
|
|
+ char *val;
|
|
|
+ val = slapi_entry_attr_get_charptr(e, "allowWeakDHParam");
|
|
|
+ if (val) {
|
|
|
+ if (!PL_strcasecmp(val, "off") || !PL_strcasecmp(val, "false") ||
|
|
|
+ !PL_strcmp(val, "0") || !PL_strcasecmp(val, "no")) {
|
|
|
+ allow = CIPHER_SET_DISALLOWWEAKDHPARAM;
|
|
|
+ } else if (!PL_strcasecmp(val, "on") || !PL_strcasecmp(val, "true") ||
|
|
|
+ !PL_strcmp(val, "1") || !PL_strcasecmp(val, "yes")) {
|
|
|
+ allow = CIPHER_SET_ALLOWWEAKDHPARAM;
|
|
|
+ slapd_SSL_warn("The value of allowWeakDHParam is set to %s. THIS EXPOSES YOU TO CVE-2015-4000.", val);
|
|
|
+ } else {
|
|
|
+ slapd_SSL_warn("The value of allowWeakDHParam \"%s\" is invalid.",
|
|
|
+ "Ignoring it and set it to default.", val);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ slapi_ch_free((void **) &val);
|
|
|
+ return allow;
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
char **
|
|
|
getEnabledCiphers()
|
|
|
{
|
|
|
@@ -1281,6 +1326,9 @@ slapd_ssl_init()
|
|
|
char *val = NULL;
|
|
|
PK11SlotInfo *slot;
|
|
|
Slapi_Entry *entry = NULL;
|
|
|
+#ifdef HAVE_NSS_DHE
|
|
|
+ SECStatus rv = SECFailure;
|
|
|
+#endif
|
|
|
|
|
|
/* Get general information */
|
|
|
|
|
|
@@ -1289,6 +1337,17 @@ slapd_ssl_init()
|
|
|
val = slapi_entry_attr_get_charptr( entry, "nssslSessionTimeout" );
|
|
|
ciphers = slapi_entry_attr_get_charptr( entry, "nsssl3ciphers" );
|
|
|
|
|
|
+#ifdef HAVE_NSS_DHE
|
|
|
+ allowweakdhparam = get_allow_weak_dh_param(entry);
|
|
|
+ if (allowweakdhparam & CIPHER_SET_ALLOWWEAKDHPARAM) {
|
|
|
+ slapd_SSL_warn("notice, generating new WEAK DH param");
|
|
|
+ rv = SSL_EnableWeakDHEPrimeGroup(NULL, PR_TRUE);
|
|
|
+ if (rv != SECSuccess) {
|
|
|
+ slapd_SSL_warn("Warning, unable to generate weak dh parameters");
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
/* We are currently using the value of sslSessionTimeout
|
|
|
for ssl3SessionTimeout, see SSL_ConfigServerSessionIDCache() */
|
|
|
/* Note from Tom Weinstein on the meaning of the timeout:
|
|
|
@@ -1856,6 +1915,24 @@ slapd_ssl_init2(PRFileDesc **fd, int startTLS)
|
|
|
}
|
|
|
|
|
|
if (SECSuccess == rv) {
|
|
|
+
|
|
|
+#ifdef HAVE_NSS_DHE
|
|
|
+ /* Step If we want weak dh params, flag it on the socket now! */
|
|
|
+
|
|
|
+ rv = SSL_OptionSet(*fd, SSL_ENABLE_SERVER_DHE, PR_TRUE);
|
|
|
+ if (rv != SECSuccess) {
|
|
|
+ slapd_SSL_warn("Warning, unable to start DHE");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (allowweakdhparam & CIPHER_SET_ALLOWWEAKDHPARAM) {
|
|
|
+ slapd_SSL_warn("notice, allowing weak parameters on socket.");
|
|
|
+ rv = SSL_EnableWeakDHEPrimeGroup(*fd, PR_TRUE);
|
|
|
+ if (rv != SECSuccess) {
|
|
|
+ slapd_SSL_warn("Warning, unable to allow weak DH params on socket.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
if( slapd_pk11_fortezzaHasKEA(cert) == PR_TRUE ) {
|
|
|
rv = SSL_ConfigSecureServer(*fd, cert, key, kt_fortezza);
|
|
|
}
|