Blame SOURCES/cyrus-imapd-2.3.16-tlsconfig.patch

62c494
New settings:
62c494
62c494
    tls_prefer_server_ciphers: 0
62c494
62c494
        Prefer the cipher order configured on the server-side.
62c494
62c494
    tls_versions: ssl2 ssl3 tls1_0 tls1_1 tls1_2
62c494
62c494
        Disable SSL/TLS protocols not in this list.
62c494
62c494
diff --git a/imap/tls.c b/imap/tls.c
62c494
index b2cf666..5a626e2 100644
62c494
--- a/imap/tls.c
62c494
+++ b/imap/tls.c
62c494
@@ -632,6 +632,7 @@ int     tls_init_serverengine(const char *ident,
62c494
     const char   *s_cert_file;
62c494
     const char   *s_key_file;
62c494
     int    requirecert;
62c494
+    int    server_cipher_order;
62c494
     int    timeout;
62c494
 
62c494
     if (tls_serverengine)
62c494
@@ -663,10 +657,40 @@ int     tls_init_serverengine(const char *ident,
62c494
     };
62c494
 
62c494
     off |= SSL_OP_ALL;		/* Work around all known bugs */
62c494
-    if (tlsonly) {
62c494
-	off |= SSL_OP_NO_SSLv2;
62c494
-	off |= SSL_OP_NO_SSLv3;
62c494
+
62c494
+    const char *tls_versions = config_getstring(IMAPOPT_TLS_VERSIONS);
62c494
+
62c494
+    if (strstr(tls_versions, "ssl2") == NULL || tlsonly) {
62c494
+    off |= SSL_OP_NO_SSLv2;
62c494
+    }
62c494
+
62c494
+    if (strstr(tls_versions, "ssl3") == NULL || tlsonly) {
62c494
+    off |= SSL_OP_NO_SSLv3;
62c494
+    }
62c494
+
62c494
+    if (strstr(tls_versions, "tls1_2") == NULL) {
62c494
+#if (OPENSSL_VERSION_NUMBER >= 0x1000105fL)
62c494
+    off |= SSL_OP_NO_TLSv1_2;
62c494
+#else
62c494
+    syslog(LOG_ERR, "ERROR: TLSv1.2 configured, OpenSSL < 1.0.1e insufficient");
62c494
+#endif
62c494
     }
62c494
+
62c494
+    if (strstr(tls_versions, "tls1_1") == NULL) {
62c494
+#if (OPENSSL_VERSION_NUMBER >= 0x1000000fL)
62c494
+    off |= SSL_OP_NO_TLSv1_1;
62c494
+#else
62c494
+    syslog(LOG_ERR, "ERROR: TLSv1.1 configured, OpenSSL < 1.0.0 insufficient");
62c494
+#endif
62c494
+    }
62c494
+    if (strstr(tls_versions, "tls1_0") == NULL) {
62c494
+    off |= SSL_OP_NO_TLSv1;
62c494
+    }
62c494
+
62c494
+    server_cipher_order = config_getswitch(IMAPOPT_TLS_PREFER_SERVER_CIPHERS);
62c494
+    if (server_cipher_order)
62c494
+        off |= SSL_OP_CIPHER_SERVER_PREFERENCE;
62c494
+
62c494
     SSL_CTX_set_options(s_ctx, off);
62c494
     SSL_CTX_set_info_callback(s_ctx, (void (*)()) apps_ssl_info_callback);
62c494
 
62c494
@@ -1196,7 +1220,7 @@ int tls_init_clientengine(int verifydepth,
62c494
 	return -1;
62c494
     }
62c494
     
62c494
-    c_ctx = SSL_CTX_new(TLSv1_client_method());
62c494
+    c_ctx = SSL_CTX_new(SSLv23_client_method());
62c494
     if (c_ctx == NULL) {
62c494
 	return (-1);
62c494
     };
62c494
diff --git a/imtest/imtest.c b/imtest/imtest.c
62c494
index 01ac72c..50d115d 100644
62c494
--- a/imtest/imtest.c
62c494
+++ b/imtest/imtest.c
62c494
@@ -510,7 +510,7 @@ static int tls_init_clientengine(int verifydepth, char *var_tls_cert_file, char
62c494
 	return IMTEST_FAIL;
62c494
     }
62c494
     
62c494
-    tls_ctx = SSL_CTX_new(TLSv1_client_method());
62c494
+    tls_ctx = SSL_CTX_new(SSLv23_client_method());
62c494
     if (tls_ctx == NULL) {
62c494
 	return IMTEST_FAIL;
62c494
     };
62c494
Index: cyrus-imapd-2.3.16/lib/imapoptions
62c494
===================================================================
62c494
--- cyrus-imapd-2.3.16.orig/lib/imapoptions
62c494
+++ cyrus-imapd-2.3.16/lib/imapoptions
62c494
@@ -1288,6 +1288,15 @@ product version in the capabilities */
62c494
    the special use flag "\Drafts" added.  Later versions of Cyrus
62c494
    have a much more flexible RFC 6154 compatible system.  */
62c494
 
62c494
+{ "tls_prefer_server_ciphers", 0, SWITCH }
62c494
+/* Prefer the ciphers on the server side instead of client side */
62c494
+
62c494
+{ "tls_versions", "ssl2 ssl3 tls1_0 tls1_1 tls1_2", STRING }
62c494
+/* A list of SSL/TLS versions to not disable. Cyrus IMAP SSL/TLS starts
62c494
+   with all protocols, and substracts protocols not in this list. Newer
62c494
+   versions of SSL/TLS will need to be added here to allow them to get
62c494
+   disabled. */
62c494
+
62c494
 /*
62c494
 .SH SEE ALSO
62c494
 .PP