【问题标题】:Using client certificate with Apache Axis 1将客户端证书与 Apache Axis 1 一起使用
【发布时间】:2015-06-12 12:22:27
【问题描述】:

先决条件

  • Apache Tomcat 7
  • 春季 3.2.11.RELEASE
  • Apache Camel 2.14.1
  • Apache Axis 1 (1.4)
  • 包含客户端证书(私钥、公钥等)的密钥库:my_keystore.p12

问题

我正在尝试使用 Apache Axis 1 访问远程 rpc/编码的 werbservice。

由于 web 服务的 rpc/encoded 风格,必须使用 Apache Axis 1。

Web 服务受 my_keystore.p12 中包含的客户端证书保护。 与远程服务器的双向 SSL 握手需要客户端证书(我的应用程序是客户端)---> 客户端检查它是否与正确的服务器通信,服务器检查它是否与正确的客户端通信。 文件 my_keystore.p12 包含在 Apache Tomcat 的类路径中。

我使用以下单元测试测试了连接:

    @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");
            }

    }

发生以下异常:

    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)

我认为问题在于密钥库不是按轴读取的。 Apache Axis 1 是否可以使用客户端证书?

提前致谢,

最大

【问题讨论】:

    标签: web-services tomcat axis client-certificates


    【解决方案1】:

    解决方案是将 JVM-Paramters 用于 truststore 和 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-24
      • 2013-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-23
      • 1970-01-01
      • 2020-01-23
      相关资源
      最近更新 更多