2016-07-06 51 views
0

我正在使用WSO2 Message Broker作为我的项目中的消息代理系统。为了获得队列信息(获得在wso2mb服务器中创建的所有队列,每个队列中的消息数等信息),我从AndesAdminServics WSDL生成客户端,并尝试从我的api调用getAllQueues()api。每次我得到无法找到有效的认证路径,以请求目标异常。我无法弄清楚有什么问题。例外的是 -证书异常在wso2消息代理中调用AndesAdminService WSDL的生成存根

Jul 06, 2016 5:21:19 PM org.apache.axis.utils.JavaUtils isAttachmentSupported 
WARNING: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled. 
AxisFault 
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException 
faultSubcode: 
faultString: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
faultActor: 
faultNode: 
faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
    at sun.security.ssl.Alerts.getSSLException(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) 
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source) 
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source) 
    at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source) 
    at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source) 
    at sun.security.ssl.Handshaker.processLoop(Unknown Source) 
    at sun.security.ssl.Handshaker.process_record(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) 
    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 org.wso2.carbon.andes.admin.AndesAdminServiceSoap11BindingStub.getAllQueues(AndesAdminServiceSoap11BindingStub.java:858) 
    at org.wso2.carbon.andes.admin.AndesAdminServicePortTypeProxy.getAllQueues(AndesAdminServicePortTypeProxy.java:62) 
    at org.wso2.carbon.andes.admin.TestClass.main(TestClass.java:11) 
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
    at sun.security.validator.PKIXValidator.doBuild(Unknown Source) 
    at sun.security.validator.PKIXValidator.engineValidate(Unknown Source) 
    at sun.security.validator.Validator.validate(Unknown Source) 
    at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source) 
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source) 
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source) 
    ... 24 more 
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
    at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source) 
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source) 
    at java.security.cert.CertPathBuilder.build(Unknown Source) 
    ... 30 more 

    {http://xml.apache.org/axis/}hostname:RIL15066YJB152 

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
    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) 
    at org.wso2.carbon.andes.admin.AndesAdminServiceSoap11BindingStub.getAllQueues(AndesAdminServiceSoap11BindingStub.java:858) 
    at org.wso2.carbon.andes.admin.AndesAdminServicePortTypeProxy.getAllQueues(AndesAdminServicePortTypeProxy.java:62) 
    at org.wso2.carbon.andes.admin.TestClass.main(TestClass.java:11) 
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
    at sun.security.ssl.Alerts.getSSLException(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) 
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source) 
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source) 
    at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source) 
    at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source) 
    at sun.security.ssl.Handshaker.processLoop(Unknown Source) 
    at sun.security.ssl.Handshaker.process_record(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) 
    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) 
    ... 12 more 
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
    at sun.security.validator.PKIXValidator.doBuild(Unknown Source) 
    at sun.security.validator.PKIXValidator.engineValidate(Unknown Source) 
    at sun.security.validator.Validator.validate(Unknown Source) 
    at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source) 
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source) 
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source) 
    ... 24 more 
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
    at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source) 
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source) 
    at java.security.cert.CertPathBuilder.build(Unknown Source) 
    ... 30 more 

我的API调用getAllQueues()方法是 -

package org.wso2.carbon.andes.admin; 

import java.rmi.RemoteException; 

public class TestClass { 

    public static void main(String args[]) { 
     AndesAdminServiceSoap11BindingStub aadptp; 
    AndesAdminServiceLocator loact = new AndesAdminServiceLocator(); 

    try { 
     aadptp = new AndesAdminServiceSoap11BindingStub(); 
     aadptp._setProperty(org.apache.axis.client.Stub.USERNAME_PROPERTY, "admin"); 
     aadptp._setProperty(org.apache.axis.client.Stub.PASSWORD_PROPERTY, "admin"); 
     aadptp._setProperty(org.apache.axis.client.Stub.ENDPOINT_ADDRESS_PROPERTY, 
       loact.getAndesAdminServiceHttpsSoap11EndpointAddress()); 

     org.wso2.carbon.andes.admin.internal.xsd.Queue[] queues = aadptp.getAllQueues(); 
     System.out.println(queues.length); 
    } catch (AxisFault e1) { 
     e1.printStackTrace(); 
    } catch (RemoteException e) { 
     e.printStackTrace(); 
    } 
    } 

} 

回答

0

首先,请尝试使用了SoapUI或任何其他的首选工具,以您访问端点。如果你可以访问它,听起来像你需要将Wso2证书添加到你的JVM密钥存储。

WSO2产品使用位于${carbon.home}/repository/resources/security/目录的自定义密钥存储区。如果您需要使用java客户端访问WSO2服务器中的任何https端点,则需要将该证书添加到位于`$ {JAVA_HOME}/lib/security/cacerts'的已用JVM的密钥库文件中。

首先,你可以检查你的证书已经在密钥库运行以下命令:keytool -list -keystore "${JAVA_HOME}/lib/security/cacerts"(不需要提供密码)

如果您的证书丢失,将其添加到与密钥库以下命令:

keytool -import -noprompt -trustcacerts -alias wso2carbon -file ${carbon.home}/repository/resources/security/ -keystore ${JAVA_HOME}/lib/security/cacerts -storepass wso2carbon