cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf git commit: [CXF-6414] - Add a way of including TLS protocols in the Jetty server
Date Tue, 19 May 2015 15:37:16 GMT
Repository: cxf
Updated Branches:
  refs/heads/master c16adcdc9 -> 96f736726


[CXF-6414] - Add a way of including TLS protocols in the Jetty server


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/96f73672
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/96f73672
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/96f73672

Branch: refs/heads/master
Commit: 96f736726871ac7cb69d04a8527c806e887d7636
Parents: c16adcd
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue May 19 16:36:57 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue May 19 16:36:57 2015 +0100

----------------------------------------------------------------------
 .../configuration/jsse/TLSServerParameters.java | 18 ++++++++
 .../jsse/TLSServerParametersConfig.java         |  3 ++
 .../schemas/configuration/security.xsd          | 20 +++++++++
 .../http_jetty/JettyHTTPServerEngine.java       | 11 +++--
 ...ttyHTTPServerEngineBeanDefinitionParser.java |  4 ++
 .../org/apache/cxf/https/ssl3/SSLv3Test.java    | 47 ++++++++++++++++++++
 .../org/apache/cxf/https/ssl3/sslv3-server.xml  | 27 +++++++++++
 7 files changed, 124 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/96f73672/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParameters.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParameters.java
b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParameters.java
index 52884c3..fe7806e 100644
--- a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParameters.java
+++ b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParameters.java
@@ -32,6 +32,7 @@ public class TLSServerParameters extends TLSParameterBase {
 
     ClientAuthentication clientAuthentication;
     List<String> excludeProtocols = new ArrayList<String>();
+    List<String> includeProtocols = new ArrayList<String>();
     
     /**
      * This parameter configures the server side to request and/or
@@ -64,5 +65,22 @@ public class TLSServerParameters extends TLSParameterBase {
         }
         return excludeProtocols;
     }
+    
+    /**
+     * This parameter sets the protocol list to include.
+     */
+    public final void setIncludeProtocols(List<String> protocols) {
+        includeProtocols = protocols;
+    }
+    
+    /**
+     * Returns the protocols to include that are associated with this endpoint.
+     */
+    public List<String> getIncludeProtocols() {
+        if (includeProtocols == null) {
+            includeProtocols = new ArrayList<String>();
+        }
+        return includeProtocols;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/96f73672/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParametersConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParametersConfig.java
b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParametersConfig.java
index a9c9cd6..137e80d 100644
--- a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParametersConfig.java
+++ b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParametersConfig.java
@@ -57,6 +57,9 @@ public class TLSServerParametersConfig
         if (params.isSetExcludeProtocols()) {
             this.setExcludeProtocols(params.getExcludeProtocols().getExcludeProtocol());
         }
+        if (params.isSetIncludeProtocols()) {
+            this.setIncludeProtocols(params.getIncludeProtocols().getIncludeProtocol());
+        }
         if (params.isSetJsseProvider()) {
             this.setJsseProvider(params.getJsseProvider());
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/96f73672/core/src/main/resources/schemas/configuration/security.xsd
----------------------------------------------------------------------
diff --git a/core/src/main/resources/schemas/configuration/security.xsd b/core/src/main/resources/schemas/configuration/security.xsd
index d53d3e6..f6e05f9 100644
--- a/core/src/main/resources/schemas/configuration/security.xsd
+++ b/core/src/main/resources/schemas/configuration/security.xsd
@@ -362,6 +362,19 @@
         </xs:sequence>
     </xs:complexType>
     
+    <xs:complexType name="IncludeProtocols">
+      <xs:annotation>
+        <xs:documentation>
+        This structure holds a list of protocols that are to be included.
+        Sometimes we want to include more protocols than the secure socket protocol, for
example
+        "SSLv2Hello".
+        </xs:documentation>
+      </xs:annotation>
+        <xs:sequence>
+           <xs:element name="includeProtocol" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+    
     <xs:complexType name="SecureRandomParameters">
       <xs:annotation>
         <xs:documentation>
@@ -566,6 +579,13 @@
                 </xs:documentation>
               </xs:annotation>
            </xs:element>
+           <xs:element name="includeProtocols" type="tns:IncludeProtocols" minOccurs="0">
+              <xs:annotation>
+                <xs:documentation>
+                This element contains the the Protocols that will be included
+                </xs:documentation>
+              </xs:annotation>
+           </xs:element>
            <xs:element name="secureRandomParameters" 
                        type="tns:SecureRandomParameters" minOccurs="0">
               <xs:annotation>

http://git-wip-us.apache.org/repos/asf/cxf/blob/96f73672/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
index 1c99054..1b43dc4 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
@@ -692,20 +692,19 @@ public class JettyHTTPServerEngine implements ServerEngine {
         
         // Jetty 9 excludes SSLv3 by default. So if we want it then we need to 
         // remove it from the default excluded protocols
-        if ("SSLv3".equals(proto)) {
+        boolean allowSSLv3 = "SSLv3".equals(proto);
+        if (allowSSLv3 || !tlsServerParameters.getIncludeProtocols().isEmpty()) {
             List<String> excludedProtocols = new ArrayList<String>();
             for (String excludedProtocol : scf.getExcludeProtocols()) {
-                if (!("SSLv3".equals(excludedProtocol) || "SSLv2Hello".equals(excludedProtocol)))
{
+                if (!(tlsServerParameters.getIncludeProtocols().contains(excludedProtocol)
+                    || (allowSSLv3 && ("SSLv3".equals(excludedProtocol) 
+                        || "SSLv2Hello".equals(excludedProtocol))))) {
                     excludedProtocols.add(excludedProtocol);
                 }
             }
             String[] revisedProtocols = new String[excludedProtocols.size()];
             excludedProtocols.toArray(revisedProtocols);
             scf.setExcludeProtocols(revisedProtocols);
-        } else if (tlsServerParameters.getExcludeProtocols().isEmpty()) {
-            // Exclude SSLv3 + SSLv2Hello by default unless the protocol is given as SSLv3
-            scf.addExcludeProtocols("SSLv3");
-            scf.addExcludeProtocols("SSLv2Hello");
         }
         
         for (String p : tlsServerParameters.getExcludeProtocols()) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/96f73672/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
index 9ee06a0..bcafe89 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java
@@ -40,6 +40,7 @@ import org.apache.cxf.configuration.security.CipherSuites;
 import org.apache.cxf.configuration.security.ClientAuthentication;
 import org.apache.cxf.configuration.security.ExcludeProtocols;
 import org.apache.cxf.configuration.security.FiltersType;
+import org.apache.cxf.configuration.security.IncludeProtocols;
 import org.apache.cxf.configuration.security.KeyManagersType;
 import org.apache.cxf.configuration.security.SecureRandomParameters;
 import org.apache.cxf.configuration.security.TLSServerParametersType;
@@ -199,6 +200,9 @@ public class JettyHTTPServerEngineBeanDefinitionParser extends AbstractBeanDefin
             } else if ("excludeProtocols".equals(ename)) {
                 mapElementToJaxbProperty((Element)n, paramsbean, ename,
                                          ExcludeProtocols.class);
+            } else if ("includeProtocols".equals(ename)) {
+                mapElementToJaxbProperty((Element)n, paramsbean, ename,
+                                         IncludeProtocols.class);
             } else if ("secureRandomParameters".equals(ename)) {
                 mapElementToJaxbProperty((Element)n, paramsbean, ename,
                                          SecureRandomParameters.class);

http://git-wip-us.apache.org/repos/asf/cxf/blob/96f73672/systests/transports-ssl3/src/test/java/org/apache/cxf/https/ssl3/SSLv3Test.java
----------------------------------------------------------------------
diff --git a/systests/transports-ssl3/src/test/java/org/apache/cxf/https/ssl3/SSLv3Test.java
b/systests/transports-ssl3/src/test/java/org/apache/cxf/https/ssl3/SSLv3Test.java
index df5dc19..44b5e4e 100644
--- a/systests/transports-ssl3/src/test/java/org/apache/cxf/https/ssl3/SSLv3Test.java
+++ b/systests/transports-ssl3/src/test/java/org/apache/cxf/https/ssl3/SSLv3Test.java
@@ -47,6 +47,7 @@ public class SSLv3Test extends AbstractBusClientServerTestBase {
     static final String PORT = allocatePort(SSLv3Server.class);
     static final String PORT2 = allocatePort(SSLv3Server.class, 2);
     static final String PORT3 = allocatePort(SSLv3Server.class, 3);
+    static final String PORT4 = allocatePort(SSLv3Server.class, 4);
     
     @BeforeClass
     public static void startServers() throws Exception {
@@ -243,6 +244,52 @@ public class SSLv3Test extends AbstractBusClientServerTestBase {
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
+ 
+    @org.junit.Test
+    public void testTLSClientToEndpointWithSSL3Allowed() throws Exception {
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = SSLv3Test.class.getResource("sslv3-client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+        
+        URL url = SOAPService.WSDL_LOCATION;
+        SOAPService service = new SOAPService(url, SOAPService.SERVICE);
+        assertNotNull("Service is null", service);   
+        final Greeter port = service.getHttpsPort();
+        assertNotNull("Port is null", port);
+        
+        updateAddressPort(port, PORT4);
+        
+        port.greetMe("Kitty");
+        
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+    
+    @org.junit.Test
+    public void testSSL3ClientToEndpointWithSSL3Allowed() throws Exception {
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = SSLv3Test.class.getResource("sslv3-client-allow.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+        
+        URL url = SOAPService.WSDL_LOCATION;
+        SOAPService service = new SOAPService(url, SOAPService.SERVICE);
+        assertNotNull("Service is null", service);   
+        final Greeter port = service.getHttpsPort();
+        assertNotNull("Port is null", port);
+        
+        updateAddressPort(port, PORT4);
+        
+        port.greetMe("Kitty");
+        
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
     
     private static final class DisableCNCheckVerifier implements HostnameVerifier {
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/96f73672/systests/transports-ssl3/src/test/resources/org/apache/cxf/https/ssl3/sslv3-server.xml
----------------------------------------------------------------------
diff --git a/systests/transports-ssl3/src/test/resources/org/apache/cxf/https/ssl3/sslv3-server.xml
b/systests/transports-ssl3/src/test/resources/org/apache/cxf/https/ssl3/sslv3-server.xml
index 3354073..53bfd42 100644
--- a/systests/transports-ssl3/src/test/resources/org/apache/cxf/https/ssl3/sslv3-server.xml
+++ b/systests/transports-ssl3/src/test/resources/org/apache/cxf/https/ssl3/sslv3-server.xml
@@ -96,5 +96,32 @@
                      address="https://localhost:${testutil.ports.SSLv3Server.3}/SoapContext/HttpsPort"

                      serviceName="s:SOAPService" 
                      endpointName="e:HttpsPort" depends-on="disallow-tls-via-configuration"/>
+                
+    <httpj:engine-factory id="tls-but-allow-ssl3">
+        <httpj:engine port="${testutil.ports.SSLv3Server.4}">
+            <httpj:tlsServerParameters>
+                <sec:keyManagers keyPassword="password">
+                    <sec:keyStore type="jks" password="password" resource="keys/Bethal.jks"/>
+                </sec:keyManagers>
+                <sec:trustManagers>
+                    <sec:keyStore type="jks" password="password" resource="keys/Truststore.jks"/>
+                </sec:trustManagers>
+                <sec:clientAuthentication want="true" required="false"/>
+                <sec:includeProtocols>
+                    <sec:includeProtocol>SSLv3</sec:includeProtocol>
+                    <sec:includeProtocol>SSLv2Hello</sec:includeProtocol>
+                </sec:includeProtocols>
+            </httpj:tlsServerParameters>
+        </httpj:engine>
+    </httpj:engine-factory>
+    
+    <jaxws:endpoint xmlns:e="http://apache.org/hello_world/services" 
+                     xmlns:s="http://apache.org/hello_world/services" 
+                     id="TLSAllowSSLv3Endpoint" 
+                     implementor="org.apache.cxf.https.ssl3.GreeterImpl" 
+                     address="https://localhost:${testutil.ports.SSLv3Server.4}/SoapContext/HttpsPort"

+                     serviceName="s:SOAPService" 
+                     endpointName="e:HttpsPort" depends-on="tls-but-allow-ssl3"/>
+    
     
 </beans>


Mime
View raw message