Blame SOURCES/pki-core-10.1.2-bz1158410.patch

eb29d7
From 02eb00b312539f455d13b8a282cc523e11f2715e Mon Sep 17 00:00:00 2001
eb29d7
From: Christina Fu <cfu@redhat.com>
eb29d7
Date: Wed, 12 Nov 2014 15:29:04 -0800
eb29d7
Subject: [PATCH] Bug 1158410 add TLS range support to server.xml by default
eb29d7
 and upgrade
eb29d7
eb29d7
---
eb29d7
 base/server/config/pkislots.cfg                    |   3 +
eb29d7
 .../python/pki/server/deployment/pkiparser.py      |  43 ++++++++-
eb29d7
 base/server/share/conf/server.xml                  |   8 +-
eb29d7
 base/server/upgrade/10.1.2/.gitignore              |   4 -
eb29d7
 base/server/upgrade/10.1.2/01-AddTLSRangeSupport   | 102 +++++++++++++++++++++
eb29d7
 5 files changed, 153 insertions(+), 7 deletions(-)
eb29d7
 delete mode 100644 base/server/upgrade/10.1.2/.gitignore
eb29d7
 create mode 100755 base/server/upgrade/10.1.2/01-AddTLSRangeSupport
eb29d7
eb29d7
diff --git a/base/server/config/pkislots.cfg b/base/server/config/pkislots.cfg
eb29d7
index ce1ac78..ffcef2d 100644
eb29d7
--- a/base/server/config/pkislots.cfg
eb29d7
+++ b/base/server/config/pkislots.cfg
eb29d7
@@ -101,4 +101,7 @@ TOMCAT_SSL2_CIPHERS_SLOT=[TOMCAT_SSL2_CIPHERS]
eb29d7
 TOMCAT_SSL3_CIPHERS_SLOT=[TOMCAT_SSL3_CIPHERS]
eb29d7
 TOMCAT_SSL_OPTIONS_SLOT=[TOMCAT_SSL_OPTIONS]
eb29d7
 TOMCAT_TLS_CIPHERS_SLOT=[TOMCAT_TLS_CIPHERS]
eb29d7
+TOMCAT_SSL_VERSION_RANGE_STREAM_SLOT=[TOMCAT_SSL_VERSION_RANGE_STREAM]
eb29d7
+TOMCAT_SSL_VERSION_RANGE_DATAGRAM_SLOT=[TOMCAT_SSL_VERSION_RANGE_DATAGRAM]
eb29d7
+TOMCAT_SSL_RANGE_CIPHERS_SLOT=[TOMCAT_SSL_RANGE_CIPHERS]
eb29d7
 TPS_DIR_SLOT=[TPS_DIR]
eb29d7
diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py
eb29d7
index df636d4..2d7fadc 100644
eb29d7
--- a/base/server/python/pki/server/deployment/pkiparser.py
eb29d7
+++ b/base/server/python/pki/server/deployment/pkiparser.py
eb29d7
@@ -899,6 +899,45 @@ class PKIConfigParser:
eb29d7
                     "/var/run/pki/tomcat/" + self.pki_master_dict['pki_instance_name'] + ".pid"
eb29d7
                 self.pki_master_dict['TOMCAT_SERVER_PORT_SLOT'] = \
eb29d7
                     self.pki_master_dict['pki_tomcat_server_port']
eb29d7
+                self.pki_master_dict['TOMCAT_SSL_VERSION_RANGE_STREAM_SLOT'] = \
eb29d7
+                    "tls1_0:tls1_2"
eb29d7
+                self.pki_master_dict['TOMCAT_SSL_VERSION_RANGE_DATAGRAM_SLOT'] = \
eb29d7
+                    "tls1_1:tls1_2"
eb29d7
+                self.pki_master_dict['TOMCAT_SSL_RANGE_CIPHERS_SLOT'] = \
eb29d7
+                    "-TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA," + \
eb29d7
+                    "-TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA," + \
eb29d7
+                    "+TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA," + \
eb29d7
+                    "+TLS_ECDH_RSA_WITH_AES_128_CBC_SHA," + \
eb29d7
+                    "+TLS_ECDH_RSA_WITH_AES_256_CBC_SHA," + \
eb29d7
+                    "-TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA," + \
eb29d7
+                    "+TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA," + \
eb29d7
+                    "+TLS_RSA_WITH_3DES_EDE_CBC_SHA," + \
eb29d7
+                    "+TLS_RSA_WITH_AES_128_CBC_SHA," + \
eb29d7
+                    "+TLS_RSA_WITH_AES_256_CBC_SHA," + \
eb29d7
+                    "+TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA," + \
eb29d7
+                    "+TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA," + \
eb29d7
+                    "-TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA," + \
eb29d7
+                    "-TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA," + \
eb29d7
+                    "-TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA," + \
eb29d7
+                    "+TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA," + \
eb29d7
+                    "+TLS_DHE_DSS_WITH_AES_128_CBC_SHA," + \
eb29d7
+                    "+TLS_DHE_DSS_WITH_AES_256_CBC_SHA," + \
eb29d7
+                    "+TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA," + \
eb29d7
+                    "+TLS_DHE_RSA_WITH_AES_128_CBC_SHA," + \
eb29d7
+                    "+TLS_DHE_RSA_WITH_AES_256_CBC_SHA," + \
eb29d7
+                    "+TLS_DHE_RSA_WITH_AES_128_CBC_SHA256," + \
eb29d7
+                    "+TLS_DHE_RSA_WITH_AES_256_CBC_SHA256," + \
eb29d7
+                    "+TLS_RSA_WITH_AES_128_CBC_SHA256," + \
eb29d7
+                    "+TLS_RSA_WITH_AES_256_CBC_SHA256," + \
eb29d7
+                    "+TLS_RSA_WITH_AES_128_GCM_SHA256," + \
eb29d7
+                    "+TLS_DHE_RSA_WITH_AES_128_GCM_SHA256," + \
eb29d7
+                    "+TLS_DHE_DSS_WITH_AES_128_GCM_SHA256," + \
eb29d7
+                    "+TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256," + \
eb29d7
+                    "+TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256," + \
eb29d7
+                    "+TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256," + \
eb29d7
+                    "+TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256," + \
eb29d7
+                    "+TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256," + \
eb29d7
+                    "+TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256"
eb29d7
                 self.pki_master_dict['TOMCAT_SSL2_CIPHERS_SLOT'] = \
eb29d7
                     "-SSL2_RC4_128_WITH_MD5," + \
eb29d7
                     "-SSL2_RC4_128_EXPORT40_WITH_MD5," + \
eb29d7
@@ -922,8 +961,8 @@ class PKIConfigParser:
eb29d7
                     "-TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA," + \
eb29d7
                     "+TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA"
eb29d7
                 self.pki_master_dict['TOMCAT_SSL_OPTIONS_SLOT'] = \
eb29d7
-                    "ssl2=true," + \
eb29d7
-                    "ssl3=true," + \
eb29d7
+                    "ssl2=false," + \
eb29d7
+                    "ssl3=false," + \
eb29d7
                     "tls=true"
eb29d7
                 self.pki_master_dict['TOMCAT_TLS_CIPHERS_SLOT'] = \
eb29d7
                     "-TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA," + \
eb29d7
diff --git a/base/server/share/conf/server.xml b/base/server/share/conf/server.xml
eb29d7
index 8fbdf0f..306ebf2 100644
eb29d7
--- a/base/server/share/conf/server.xml
eb29d7
+++ b/base/server/share/conf/server.xml
eb29d7
@@ -142,6 +142,9 @@ Tomcat Port         = [TOMCAT_SERVER_PORT] (for shutdown)
eb29d7
               'ssl2Ciphers'
eb29d7
               'ssl3Ciphers'
eb29d7
               'tlsCiphers'
eb29d7
+              'sslVersionRangeStream'
eb29d7
+              'sslVersionRangeDatagram'
eb29d7
+              'sslRangeCiphers'
eb29d7
               'serverCertNickFile'
eb29d7
               'passwordFile'
eb29d7
               'passwordClass'
eb29d7
@@ -184,12 +187,15 @@ Tomcat Port         = [TOMCAT_SERVER_PORT] (for shutdown)
eb29d7
            ocspMinCacheEntryDuration="60"
eb29d7
            ocspMaxCacheEntryDuration="120"
eb29d7
            ocspTimeout="10"
eb29d7
-           strictCiphers="false"
eb29d7
+           strictCiphers="true"
eb29d7
            clientAuth="[PKI_AGENT_CLIENTAUTH]"
eb29d7
            sslOptions="[TOMCAT_SSL_OPTIONS]"
eb29d7
            ssl2Ciphers="[TOMCAT_SSL2_CIPHERS]"
eb29d7
            ssl3Ciphers="[TOMCAT_SSL3_CIPHERS]"
eb29d7
            tlsCiphers="[TOMCAT_TLS_CIPHERS]"
eb29d7
+           sslVersionRangeStream="[TOMCAT_SSL_VERSION_RANGE_STREAM]"
eb29d7
+           sslVersionRangeDatagram="[TOMCAT_SSL_VERSION_RANGE_DATAGRAM]"
eb29d7
+           sslRangeCiphers="[TOMCAT_SSL_RANGE_CIPHERS]"
eb29d7
            serverCertNickFile="[PKI_INSTANCE_PATH]/conf/serverCertNick.conf"
eb29d7
            passwordFile="[PKI_INSTANCE_PATH]/conf/password.conf"
eb29d7
            passwordClass="org.apache.tomcat.util.net.jss.PlainPasswordFile"
eb29d7
diff --git a/base/server/upgrade/10.1.2/.gitignore b/base/server/upgrade/10.1.2/.gitignore
eb29d7
deleted file mode 100644
eb29d7
index 5e7d273..0000000
eb29d7
--- a/base/server/upgrade/10.1.2/.gitignore
eb29d7
+++ /dev/null
eb29d7
@@ -1,4 +0,0 @@
eb29d7
-# Ignore everything in this directory
eb29d7
-*
eb29d7
-# Except this file
eb29d7
-!.gitignore
eb29d7
diff --git a/base/server/upgrade/10.1.2/01-AddTLSRangeSupport b/base/server/upgrade/10.1.2/01-AddTLSRangeSupport
eb29d7
new file mode 100755
eb29d7
index 0000000..b5b83f4
eb29d7
--- /dev/null
eb29d7
+++ b/base/server/upgrade/10.1.2/01-AddTLSRangeSupport
eb29d7
@@ -0,0 +1,102 @@
eb29d7
+#!/usr/bin/python
eb29d7
+# Authors:
eb29d7
+#     Christina Fu <cfu@redhat.com>
eb29d7
+#     Endi S. Dewata <edewata@redhat.com>
eb29d7
+#
eb29d7
+# This program is free software; you can redistribute it and/or modify
eb29d7
+# it under the terms of the GNU General Public License as published by
eb29d7
+# the Free Software Foundation; version 2 of the License.
eb29d7
+#
eb29d7
+# This program is distributed in the hope that it will be useful,
eb29d7
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
eb29d7
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
eb29d7
+# GNU General Public License for more details.
eb29d7
+#
eb29d7
+# You should have received a copy of the GNU General Public License along
eb29d7
+# with this program; if not, write to the Free Software Foundation, Inc.,
eb29d7
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
eb29d7
+#
eb29d7
+# Copyright (C) 2014 Red Hat, Inc.
eb29d7
+# All rights reserved.
eb29d7
+#
eb29d7
+
eb29d7
+import os
eb29d7
+from lxml import etree
eb29d7
+
eb29d7
+import pki.server.upgrade
eb29d7
+
eb29d7
+
eb29d7
+class AddTLSRangeSupport(pki.server.upgrade.PKIServerUpgradeScriptlet):
eb29d7
+
eb29d7
+    def __init__(self):
eb29d7
+
eb29d7
+        self.message = 'Add TLS Range Support'
eb29d7
+
eb29d7
+        self.parser = etree.XMLParser(remove_blank_text=True)
eb29d7
+
eb29d7
+
eb29d7
+    def upgrade_instance(self, instance):
eb29d7
+
eb29d7
+        server_xml = os.path.join(instance.conf_dir, 'server.xml')
eb29d7
+        #Backup the file before modify
eb29d7
+        self.backup(server_xml)
eb29d7
+        #Parse the server.xml into an XML object
eb29d7
+        document = etree.parse(server_xml, self.parser)
eb29d7
+        #perform the upgrade in memory
eb29d7
+        self.add_tls_range(document)
eb29d7
+        #Once all changes are made, write the XML back into the same server.xml
eb29d7
+        #This way we're preserving any other customization that has been done
eb29d7
+        # to the server.xml
eb29d7
+        with open(server_xml, 'w') as f:
eb29d7
+            f.write(etree.tostring(document, pretty_print=True))
eb29d7
+
eb29d7
+    def add_tls_range(self, document):
eb29d7
+
eb29d7
+        # Find existing Connector
eb29d7
+        server = document.getroot()
eb29d7
+        connectors = server.findall('.//Connector')
eb29d7
+
eb29d7
+        for connector in connectors:
eb29d7
+
eb29d7
+            secure = connector.get('secure')
eb29d7
+            if secure == 'true':
eb29d7
+                # Update Connector's attributes
eb29d7
+                connector.set('strictCiphers', 'true')
eb29d7
+                connector.set('sslVersionRangeStream', 'tls1_0:tls1_2')
eb29d7
+                connector.set('sslVersionRangeDatagram', 'tls1_1:tls1_2')
eb29d7
+                connector.set('sslRangeCiphers',
eb29d7
+                    '-TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,' \
eb29d7
+                    '-TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,' \
eb29d7
+                    '+TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,' \
eb29d7
+                    '+TLS_ECDH_RSA_WITH_AES_128_CBC_SHA,' \
eb29d7
+                    '+TLS_ECDH_RSA_WITH_AES_256_CBC_SHA,' \
eb29d7
+                    '-TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA,' \
eb29d7
+                    '+TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,' \
eb29d7
+                    '+TLS_RSA_WITH_3DES_EDE_CBC_SHA,' \
eb29d7
+                    '+TLS_RSA_WITH_AES_128_CBC_SHA,' \
eb29d7
+                    '+TLS_RSA_WITH_AES_256_CBC_SHA,' \
eb29d7
+                    '+TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,' \
eb29d7
+                    '+TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,' \
eb29d7
+                    '-TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,' \
eb29d7
+                    '-TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,' \
eb29d7
+                    '-TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,' \
eb29d7
+                    '+TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA,' \
eb29d7
+                    '+TLS_DHE_DSS_WITH_AES_128_CBC_SHA,' \
eb29d7
+                    '+TLS_DHE_DSS_WITH_AES_256_CBC_SHA,' \
eb29d7
+                    '+TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,' \
eb29d7
+                    '+TLS_DHE_RSA_WITH_AES_128_CBC_SHA,' \
eb29d7
+                    '+TLS_DHE_RSA_WITH_AES_256_CBC_SHA,' \
eb29d7
+                    '+TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,' \
eb29d7
+                    '+TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,' \
eb29d7
+                    '+TLS_RSA_WITH_AES_128_CBC_SHA256,' \
eb29d7
+                    '+TLS_RSA_WITH_AES_256_CBC_SHA256,' \
eb29d7
+                    '+TLS_RSA_WITH_AES_128_GCM_SHA256,' \
eb29d7
+                    '+TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,' \
eb29d7
+                    '+TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,' \
eb29d7
+                    '+TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,' \
eb29d7
+                    '+TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,' \
eb29d7
+                    '+TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,' \
eb29d7
+                    '+TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,' \
eb29d7
+                    '+TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,' \
eb29d7
+                    '+TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256')
eb29d7
+
eb29d7
eb29d7