当前位置: 首页 > 知识库问答 >
问题:

axis2的双向ssl导致读取超时

查修谨
2023-03-14

我正在尝试使用一个需要双向ssl身份验证的web服务,它属于一家公司X。我在axis2中创建了一个客户端,并将其配置为支持https(将服务器证书导入信任库,设置密钥库路径..等等)。当我调用它时,我不允许读取超时异常。我应该提到的是,握手是通过的,关于证书没有例外(我已经处理过)。

我做了以下工作(单独和组合):
-使用了axis2的壁垒,
-调低了我计算机上的防火墙,
-绕过了我公司的防火墙(从isp获得了单独的adsl线路),
-在公司的X帮助台记录了一张票寻求帮助,但他们说他们这边没问题。

所有这些都没有帮助,所以我使用Fiddler来监控网络流量,结果证明它在特定配置下工作:
-rampart关闭,
-在我的计算机和公司的防火墙后面,
-Fiddler捕获打开(Fiddler代理的https流量)。

当我关闭fiddler并移除代理时,仍然会出现读取超时异常。

org.apache.axis2.AxisFault: Read timed out
        at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
        at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:197)
        at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
        at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
        at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
        at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
        at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
        at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
        at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        ...
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:148)
        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:775)
        at javax.faces.component.UICommand.broadcast(UICommand.java:300)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
    Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:152)
        at java.net.SocketInputStream.read(SocketInputStream.java:122)
        at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
        at sun.security.ssl.InputRecord.read(InputRecord.java:480)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
        at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)
        at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
        at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
        at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
        at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
        at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
        at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
        at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
        at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
        at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
        at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621)
        at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
        ... 76 more

原因可能是什么?请帮我解决这个问题。非常感谢。

[编辑]

我忘了提到我曾尝试设置不同的超时值,但没有帮助。值大于4分钟会导致

'java.net.SocketException: Connection reset'  

使用Fiddler的方法即使在默认超时的情况下也能工作。我立刻得到了回复。

我已经调试了SSL连接并将其与此示例进行了比较:调试SSL/TLS连接,似乎初始握手是可以的,并且所有证书/密钥都在服务器和客户端之间正确交换。这既包括有Fiddler也包括没有Fiddler,所以我不知道为什么我在没有Fiddler运行的情况下一直被读取超时。

共有3个答案

邹书
2023-03-14

从下面的错误中,

Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:152)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
    at sun.security.ssl.InputRecord.read(InputRecord.java:480)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)

...

另一种可能的解决方案是将服务器认证导入您受信任的密钥库。

朱俭
2023-03-14

“读取超时”意味着服务器响应客户端请求的时间太长,客户端放弃了等待。如果服务运营商认为他们的服务运行正常,您可能需要调整客户端,使其等待服务响应的时间更长。

不幸的是,有三种不同的方法可以为客户端设置超时,从Internet上的信息中并不清楚每个超时到底控制了什么。看看这两个页面:

  • 如何在客户端配置Axis2的HTTP传输发送器

第一页说明了如何获取服务客户端及其选项,以及如何调用选项。setTimeOutingMillimes()设置超时。Axis2文档将其描述为“在阻塞场景中客户端超时后的等待时间”,我认为这是您想要的超时。

第二页说明如何从选项设置SO_超时连接_超时。这里可能与超时有关。

莫振
2023-03-14

我们也遇到了类似的问题,在尝试调用一个安全的Web服务时出现了读取超时,经过长时间的分析,我们发现传输协议版本不匹配。Web服务正在http1上提供服务。0,我们使用http1调用它。1.我们修改了客户端代码中的协议版本,解决了这个问题:

下面是指定超文本传输协议版本-1.0的代码

options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,
      org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);
 类似资料:
  • 对于双向SSL是如何工作的,我有些困惑。客户端如何创建要发送到服务器的证书?是否从服务器生成并分发到客户端? 另外,与单向SSL相比,双向SSL的优势是什么?

  • 所以,我正在使用Hibernate 5和SpringMVC 4制作这个网络应用程序。出于某种原因,我无法插入具有OneTo很多关系的实体。在我首先解释任何事情之前,我想说我尝试了这里和其他论坛上发布的许多解决方案,但都不适合我...我不知道我在尝试解决问题时是否做错了什么。 现在,我最近添加了phone表。在此之前,我可以添加一个配置文件对象,它会级联同一事务中地址和用户实体的插入。现在,随着将电

  • 如果我正确理解SSL/TLS在仅服务器身份验证中的含义,那么在握手之后,服务器会向客户端发送它的公钥和一个由CA签名的数字签名证书。如果客户端拥有这个CA的公钥,它就可以解密证书并与服务器建立信任。如果它不信任CA,则通信停止。在双向SSL中,客户端需要向服务器进行身份验证,在客户端接收到公钥和数字签名的证书之后,客户端将向服务器发送它的公钥和数字签名的证书。服务器将检查它是否有客户机证书的公钥,

  • 我使用Nginx作为反向代理,它接收请求,然后执行proxy_pass以从运行在8001端口上的上游服务器获得实际的web应用程序。 如果我转到mywebsite.com或执行wget,我会在60秒后获得504网关超时...但是,如果我加载mywebsite.com:8001,应用程序将按预期加载! 和Nginx错误日志的输出:

  • 我试图使用nginx作为双向SSL/相互SSL的web逻辑的反向代理。 客户端<=双向SSL=>NGINX<=双向SSL=>WebLogic服务器 客户端到NGINX双向SSL工作良好,但在上游连接到web逻辑上出现以下错误。 nginx调试日志: 以下是我对上游的nginx配置: 我尝试了各种选项,包括注释下面的配置。 如果我尝试使用openssl c_client命令行,我能够连接并获得HTT

  • 我试图设置2方式ssl身份验证。我的要求是经纪人应该只认证特定的客户。 我的组织有一个CA,它发行pkcs12格式的所有证书。我遵循的步骤如下。 获取代理的证书,并在代理密钥库中配置它 当我运行代理和客户端时,我希望代理验证客户端并建立ssl连接。但是下面的错误被抛出。 当我用只包含CA证书的信任存储文件替换 /etc/pki/java/cacerts代理信任存储时,它工作得很好。但是它将验证任何