2016-07-06 43 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