使用SSL进行相互身份验证

时间:2017-06-20 09:10:46

标签: web-services ssl axis2 mutual-authentication

我尝试使用存根通过rmi连接到Web服务。它在连接之前需要SSL握手。因此,对于证书,我访问了webservice url,将证书导出到.cer文件并将证书导入我的密钥库中

keystore -importcert -alias alias -keystore keystore.jks -file certificate.cer

并且导入了证书,然后我将相同的证书添加到我的信任库中:path-to-jre / lib / security / cacerts 此外,web服务要求在调用时使用用户名和密码,并使用以下命令设置:

 ((javax.xml.rpc.Stub) proxy)._setProperty(org.apache.axis.client.Stub.USERNAME_PROPERTY,
        "username");
((javax.xml.rpc.Stub) proxy)._setProperty(org.apache.axis.client.Stub.PASSWORD_PROPERTY,
        "password"));

我将密钥库设置为: 路径到密钥存储/ keystore.jks 和信任库的路径: path-to-jre / lib / security / cacerts

此外,我在调用调用之前使用此代码设置密钥库和信任:

System.setProperty("javax.net.ssl.keyStore", "C:/FAST/JDK64/LINKS/JDK8/bin/abc.jks");
                System.setProperty("javax.net.ssl.trustStrore",
                        "C:/FAST/JDK64/LINKS/JDK8/jre/lib/security/cacerts");
                //"C:/FAST/JDK64/LINKS/JDK8/jre/lib/security/cacerts"
                System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
                System.setProperty("javax.net.ssl.trustStorePassword", "changeit");

当启动握手时,我得到以下堆栈跟踪:

{http://xml.apache.org/axis/}stackTrace:javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:186)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
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)
at com.good.gc10.GCSoapBindingStub.getUser(GCSoapBindingStub.java:6590)
at com.good.gc10.GcServerProxy.getUser(GcServerProxy.java:343)

0 个答案:

没有答案