无法为客户端创建SSL套接字工厂

问题描述 投票:0回答:2

我正在使用Java 1.5.0_16(JBoss-4.2.3.GA应用程序)。我的应用程序实现了一个需要与外部Web服务集成的WS客户端。此通信需要通过https处理。当我尝试通过Web服务调用远程Api时,我收到以下错误。anybosy帮助我可能是什么原因

14:25:17,609 WARN  [HTTPClientInvoker] Unable to create SSL Socket Factory for client invoker: Error initializing socket factory SSL context: Can not find truststore url.
14:25:18,203 INFO  [STDOUT] ERROR:
14:25:18,203 ERROR [STDERR] javax.xml.ws.WebServiceException: java.io.IOException: Could not transmit message
14:25:18,203 ERROR [STDERR]     at org.jboss.ws.core.jaxws.client.ClientImpl.handleRemoteException(ClientImpl.java:404)
14:25:18,203 ERROR [STDERR]     at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:314)
14:25:18,203 ERROR [STDERR]     at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:172)
14:25:18,203 ERROR [STDERR]     at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:152)
14:25:18,203 ERROR [STDERR]     at $Proxy95.getConnectionDetails(Unknown Source)
14:25:18,203 ERROR [STDERR]     at testjava.Test.testWebservice(Test.java:113)
14:25:18,203 ERROR [STDERR]     at com.digital88.billing.dao.WholesalerDAOImpl.findByUserNameAndPassword(WholesalerDAOImpl.java:61)
14:25:18,203 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:25:18,203 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
14:25:18,203 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
14:25:18,203 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:585)
14:25:18,203 ERROR [STDERR]     at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
14:25:18,203 ERROR [STDERR]     at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
14:25:18,203 ERROR [STDERR]     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
14:25:18,203 ERROR [STDERR]     at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
14:25:18,203 ERROR [STDERR]     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
14:25:18,203 ERROR [STDERR]     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
14:25:18,203 ERROR [STDERR]     at $Proxy79.findByUserNameAndPassword(Unknown Source)
14:25:18,203 ERROR [STDERR]     at com.digital88.billing.services.WholesalerServiceImpl.authenticate(WholesalerServiceImpl.java:67)
14:25:18,203 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:25:18,203 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
14:25:18,203 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
14:25:18,203 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:585)
14:25:18,203 ERROR [STDERR]     at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:406)
14:25:18,203 ERROR [STDERR]     at net.sf.gilead.blazeds.adapter.PersistentAdapter.invoke(PersistentAdapter.java:123)
14:25:18,203 ERROR [STDERR]     at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
14:25:18,203 ERROR [STDERR]     at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1417)
14:25:18,203 ERROR [STDERR]     at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:878)
14:25:18,203 ERROR [STDERR]     at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:121)
14:25:18,203 ERROR [STDERR]     at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
14:25:18,203 ERROR [STDERR]     at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:49)
14:25:18,203 ERROR [STDERR]     at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
14:25:18,203 ERROR [STDERR]     at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:146)
14:25:18,203 ERROR [STDERR]     at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:274)
14:25:18,203 ERROR [STDERR]     at flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:377)
14:25:18,203 ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
14:25:18,203 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
14:25:18,203 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
14:25:18,203 ERROR [STDERR]     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
14:25:18,203 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
14:25:18,203 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
14:25:18,203 ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
14:25:18,203 ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
14:25:18,203 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
14:25:18,203 ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
14:25:18,203 ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
14:25:18,203 ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
14:25:18,203 ERROR [STDERR]     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
14:25:18,203 ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
14:25:18,203 ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
14:25:18,203 ERROR [STDERR]     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
14:25:18,203 ERROR [STDERR]     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
14:25:18,203 ERROR [STDERR]     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
14:25:18,203 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:595)
14:25:18,203 ERROR [STDERR] Caused by: java.io.IOException: Could not transmit message
14:25:18,203 ERROR [STDERR]     at org.jboss.ws.core.client.HTTPRemotingConnection.invoke(HTTPRemotingConnection.java:255)
14:25:18,203 ERROR [STDERR]     at org.jboss.ws.core.client.SOAPProtocolConnectionHTTP.invoke(SOAPProtocolConnectionHTTP.java:73)
14:25:18,203 ERROR [STDERR]     at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:339)
14:25:18,203 ERROR [STDERR]     at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:302)
14:25:18,203 ERROR [STDERR]     ... 52 more
14:25:18,203 ERROR [STDERR] Caused by: org.jboss.remoting.CannotConnectException: Can not connect http client invoker. cannot retry due to redirection, in streaming mode. Response
: Found/302.
14:25:18,203 ERROR [STDERR]     at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:348)
14:25:18,203 ERROR [STDERR]     at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:137)
14:25:18,203 ERROR [STDERR]     at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
14:25:18,203 ERROR [STDERR]     at org.jboss.remoting.Client.invoke(Client.java:1634)
14:25:18,203 ERROR [STDERR]     at org.jboss.remoting.Client.invoke(Client.java:548)
14:25:18,203 ERROR [STDERR]     at org.jboss.ws.core.client.HTTPRemotingConnection.invoke(HTTPRemotingConnection.java:233)
14:25:18,203 ERROR [STDERR]     ... 55 more
14:25:18,203 ERROR [STDERR] Caused by: java.net.HttpRetryException: cannot retry due to redirection, in streaming mode
14:25:18,203 ERROR [STDERR]     at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:1695)
14:25:18,203 ERROR [STDERR]     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1106)
14:25:18,203 ERROR [STDERR]     at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:367)
14:25:18,203 ERROR [STDERR]     at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)
14:25:18,203 ERROR [STDERR]     at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:282)
14:25:18,203 ERROR [STDERR]     ... 60 more
14:25:18,203 INFO  [STDOUT] connectionDetails..
web-services configuration jboss
2个回答
0
投票

我有两个可能的解决方案:

  • 堆栈跟踪链包含消息的嵌套异常

org.jboss.remoting.CannotConnectException:无法连接http客户端调用程序。在流模式下,由于重定向无法重试。回复:找到/ 302

所以你绝对确定你指的是正确的URL吗?看起来JBoss代码没有处理302重定向。

  • 我有一个模糊的内存,为了在JBoss中使用客户端SSL,首先需要配置服务器端部分

换句话说,您的JBOss的Web服务器必须完全配置其SSL连接器,以便从客户端调用接收异步回调。这听起来很愚蠢,但值得研究,因为我之前遇到过类似的事情。

所以在jboss-web的server.xml中挖掘一下,看看SSL连接器是否在那里并进行了配置。这个配置包括一个密钥库URL,如果没有配置,可能会解释“找不到密钥库”异常。


0
投票

我意识到这是一个非常古老的问题。无论如何我想我会试着回答它。

通常在使用SSL连接时,您需要设置javax.net.ssl.trustStore属性。应从服务器上使用的证书中提取trustStore。

您可以明确允许重定向

HttpURLConnection.setFollowRedirects(true);

您也可以关闭主机名验证。 (这在服务器证书的cn与服务器主机名不匹配的测试环境中非常有用。)

HostnameVerifier hostnameVerifier = new HostnameVerifier() {
    public boolean verify(String urlHostName, SSLSession session) {
        return true;
    }
};
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);

希望这有助于某人。

© www.soinside.com 2019 - 2024. All rights reserved.