Using client certificate with Apache Axis 1

Prerequisites

  • Apache Tomcat 7
  • Spring 3.2.11.RELEASE
  • Apache Camel 2.14.1
  • Apache Axis 1 (1.4)
  • Keystore including client certificate (private key, public key, etc.): my_keystore.p12

Question

I am trying to access a remote rpc / encoded werbservice using Apache Axis 1.

Must be using Apache Axis 1 due to the rpc / encoded webservice style.

The web service is protected by a client certificate contained in my_keystore.p12. The client certificate is required for a bi-directional SSL connection to the remote server (my ad is the client) ---> the client checks if it is talking about the correct server and the server checks if it leads to the correct client. The my_keystore.p12 file is contained in the Apache Tomcat classpath.

I have tested the connection with the following Unit-Test:

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration("classpath:spring-test-config.xml")
    public class MyClientTest {

            private static MyWebservices webservices;

            @BeforeClass
            public static void initializeWebservices()  throws IllegalStateException {
                    if (webservices == null ) {
                    URL servicesUrl;
                    try {
                            servicesUrl = new URL("https://examplehost.com/abcd/abcdefg/rpcrouter");

                            AxisProperties.getProperties().put("proxySet", "true");
                            AxisProperties.setProperty("http.proxyHost", "11.222.333.44");
                            AxisProperties.setProperty("http.proxyPort", "80");

                            AxisProperties.setProperty("keystore", "my_keystore.p12");
                            AxisProperties.setProperty("keystorePassword", "abc");
                            AxisProperties.setProperty("keystoreType", "pkcs12");

                    } catch (MalformedURLException e) {
                            throw new IllegalStateException(e.getMessage());
                    }
                    try {
                            webservices = new MyWebservicesServiceLocator().getrpcrouter(servicesUrl);
                    } catch (ServiceException e) {
                            throw new IllegalStateException(e.getMessage());
                    }
                    }
            }

            @Test
            public void testConnection() throws Exception {
                    webservices.doSomething("2");
            }

    }

      

The following exception is thrown:

    javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
            at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
            at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
            at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
            at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
            at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
            at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
            at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
            at org.apache.axis.client.Call.invoke(Call.java:2767)
            at org.apache.axis.client.Call.invoke(Call.java:2443)
            at org.apache.axis.client.Call.invoke(Call.java:2366)
            at org.apache.axis.client.Call.invoke(Call.java:1812)

      

I think the problem is that the keystore is not being read by the axis. Can client certificates be used with Apache Axis 1?

Thanks in advance,

Max

+3


source to share


1 answer


The solutions are to use JVM-Paramters for trust and keystore.



java 
-Djavax.net.ssl.trustStore=/some/path/myTruststore.jks
-Djavax.net.ssl.trustStorePassword=abc

-Djavax.net.ssl.keyStore=/some/path/myKeystore.p12
-Djavax.net.ssl.keyStorePassword=defg
-Djavax.net.ssl.keyStoreType=PKCS12

      

+2


source







All Articles