You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2016/04/05 15:03:51 UTC

[2/3] cxf git commit: Adding a TLS test for an expired cert

Adding a TLS test for an expired cert


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

Branch: refs/heads/3.1.x-fixes
Commit: 3235f4be3d12aee0088910d69bb67bc5db554df9
Parents: 7f17ddd
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Tue Apr 5 12:46:26 2016 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Tue Apr 5 14:03:45 2016 +0100

----------------------------------------------------------------------
 .../https/ciphersuites/CipherSuitesTest.java    |  31 ++++++++++++++++
 .../src/test/resources/keys/wss40exp.jks        | Bin 0 -> 3941 bytes
 .../src/test/resources/keys/wss40expCA.jks      | Bin 0 -> 858 bytes
 .../ciphersuites-client-expired-cert.xml        |  37 +++++++++++++++++++
 .../https/ciphersuites/ciphersuites-server.xml  |  28 ++++++++++++++
 5 files changed, 96 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/3235f4be/systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java
----------------------------------------------------------------------
diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java b/systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java
index dd3ced4..d85c75a 100644
--- a/systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java
+++ b/systests/transports/src/test/java/org/apache/cxf/systest/https/ciphersuites/CipherSuitesTest.java
@@ -72,6 +72,7 @@ public class CipherSuitesTest extends AbstractBusClientServerTestBase {
     static final String PORT2 = allocatePort(CipherSuitesServer.class, 2);
     static final String PORT3 = allocatePort(CipherSuitesServer.class, 3);
     static final String PORT4 = allocatePort(CipherSuitesServer.class, 4);
+    static final String PORT5 = allocatePort(CipherSuitesServer.class, 5);
     
     @BeforeClass
     public static void startServers() throws Exception {
@@ -621,6 +622,36 @@ public class CipherSuitesTest extends AbstractBusClientServerTestBase {
         bus.shutdown(true);
     }
     
+    // Test an expired cert
+    @org.junit.Test
+    public void testExpiredCert() throws Exception {
+        
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = CipherSuitesTest.class.getResource("ciphersuites-client-expired-cert.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, PORT5);
+        
+        try {
+            port.greetMe("Kitty");
+            fail("Failure expected on not being able to negotiate a cipher suite");
+        } catch (Exception ex) {
+            // expected
+        }
+        
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+    
     private static class NoOpX509TrustManager implements X509TrustManager {
 
         NoOpX509TrustManager() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/3235f4be/systests/transports/src/test/resources/keys/wss40exp.jks
----------------------------------------------------------------------
diff --git a/systests/transports/src/test/resources/keys/wss40exp.jks b/systests/transports/src/test/resources/keys/wss40exp.jks
new file mode 100644
index 0000000..1ee7be7
Binary files /dev/null and b/systests/transports/src/test/resources/keys/wss40exp.jks differ

http://git-wip-us.apache.org/repos/asf/cxf/blob/3235f4be/systests/transports/src/test/resources/keys/wss40expCA.jks
----------------------------------------------------------------------
diff --git a/systests/transports/src/test/resources/keys/wss40expCA.jks b/systests/transports/src/test/resources/keys/wss40expCA.jks
new file mode 100644
index 0000000..886d85c
Binary files /dev/null and b/systests/transports/src/test/resources/keys/wss40expCA.jks differ

http://git-wip-us.apache.org/repos/asf/cxf/blob/3235f4be/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-client-expired-cert.xml
----------------------------------------------------------------------
diff --git a/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-client-expired-cert.xml b/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-client-expired-cert.xml
new file mode 100644
index 0000000..0e92933
--- /dev/null
+++ b/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-client-expired-cert.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ 
+ http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:http="http://cxf.apache.org/transports/http/configuration" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core" xmlns:p="http://cxf.apache.org/policy" xmlns:sec="http://cxf.apache.org/configuration/security" xsi:schemaLocation="           http://www.springframework.org/schema/beans           http://www.springframework.org/schema/beans/spring-beans.xsd           http://cxf.apache.org/jaxws                           http://cxf.apache.org/schemas/jaxws.xsd           http://cxf.apache.org/transports/http/configuration   http://cxf.apache.org/schemas/configuration/http-conf.xsd           http://cxf.apache.org/configuration/security          http://cxf.apache.org/schemas/configuration/security.xsd           http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd           http://cxf.apache.org/policy http://cxf.apache.org/schemas/poli
 cy.xsd">
+    
+    <cxf:bus>
+        <cxf:features>
+            <cxf:logging/>
+        </cxf:features>
+    </cxf:bus>
+    <http:conduit name="https://localhost:.*">
+        <http:tlsClientParameters disableCNCheck="true" secureSocketProtocol="TLSv1.2">
+            <sec:trustManagers>
+                <sec:keyStore type="jks" password="security" resource="keys/wss40expCA.jks"/>
+            </sec:trustManagers>
+            <sec:cipherSuites>
+                <sec:cipherSuite>TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256</sec:cipherSuite>
+            </sec:cipherSuites>
+        </http:tlsClientParameters>
+    </http:conduit>
+</beans>

http://git-wip-us.apache.org/repos/asf/cxf/blob/3235f4be/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-server.xml
----------------------------------------------------------------------
diff --git a/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-server.xml b/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-server.xml
index e5b382e..83e6c3f 100644
--- a/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-server.xml
+++ b/systests/transports/src/test/resources/org/apache/cxf/systest/https/ciphersuites/ciphersuites-server.xml
@@ -120,4 +120,32 @@
                      address="https://localhost:${testutil.ports.CipherSuitesServer.4}/SoapContext/HttpsPort" 
                      serviceName="s:SOAPService" 
                      endpointName="e:HttpsPort" depends-on="aes-explicit-tls-settings"/>
+                     
+    <httpj:engine-factory id="expired-cert-tls-settings">
+        <httpj:engine port="${testutil.ports.CipherSuitesServer.5}">
+            <httpj:tlsServerParameters>
+                <sec:keyManagers keyPassword="security">
+                    <sec:keyStore type="jks" password="security" resource="keys/wss40exp.jks"/>
+                </sec:keyManagers>
+                <sec:clientAuthentication want="false" required="false"/>
+                <sec:cipherSuitesFilter>
+                    <sec:include>.*_WITH_AES_.*</sec:include>
+                </sec:cipherSuitesFilter>
+            </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="AESExpiredCertTLSServer" 
+                     implementor="org.apache.cxf.systest.http.GreeterImpl" 
+                     address="https://localhost:${testutil.ports.CipherSuitesServer.5}/SoapContext/HttpsPort" 
+                     serviceName="s:SOAPService" 
+                     endpointName="e:HttpsPort" depends-on="expired-cert-tls-settings">
+        <jaxws:inInterceptors>
+            <bean class="org.apache.cxf.systest.https.ciphersuites.CipherSuiteChecker">
+                <property name="requiredAlgorithm" value="AES"/>
+            </bean>
+        </jaxws:inInterceptors>
+    </jaxws:endpoint>
 </beans>