HTML   发布时间:2022-04-14  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了web-services – java webservice客户端中的握手异常大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试为安全的https连接实现webclient.我导入了服务器证书并将其添加到 java密钥库.但是当我尝试运行客户端时,我得到以下例外: –
Oct 18,2013 3:25:25 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging WARNING: Interceptor for 

{http://tempuri.org/}service#{http://tempuri.org/}GetUserInformation has thrown exception,unwinding now org.apache.cxf.interceptor.Fault: Could not send message.
    at 
org.apache.cxf.interceptor.messageSenderInterceptor$messageSenderEndingInterceptor.handlemessage(messageSenderInterceptor.java:64)
    at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
    at $Proxy29.getUserInformation(Unknown sourcE)
    at 
org.tempuri.serviceSoap_serviceSoap_Client.main(serviceSoap_serviceSoap_Client.java:78)
Caused by: java.io.IOException: IOException invoking 
myurl/**/**/asmx: The https URL hostname does not 
match the Common Name (CN) on the server certificate in the client's truststore.  Make sure 
server certificate is correct,or to disable this check (NOT recommended for production) set the CXF client TLS configuration property "disableCNcheck" to true.
    at sun.reflect.NativeConstructOraccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructOraccessorImpl.newInstance(Unknown sourcE)
    at sun.reflect.DelegaTingConstructOraccessorImpl.newInstance(Unknown sourcE)
    at java.lang.reflect.Constructor.newInstance(Unknown sourcE)
    at 
org.apache.cxf.transport.http.httpConduit$WrappedOutputStream.mapException(httpConduit.java:1338)
    at 
org.apache.cxf.transport.http.httpConduit$WrappedOutputStream.close(httpConduit.java:1322)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.httpConduit.close(httpConduit.java:627)
    at 
org.apache.cxf.interceptor.messageSenderInterceptor$messageSenderEndingInterceptor.handlemessage(messageSenderInterceptor.java:62)
    ... 9 more
Caused by: java.io.IOException: The https URL hostname does not match the Common Name (CN) 
on the server certificate in the client's truststore.  Make sure server certificate is 
correct,or to disable this check (NOT recommended for production) set the CXF client TLS 
configuration property "disableCNcheck" to true.
    at 
org.apache.cxf.transport.http.httpConduit$WrappedOutputStream.onFirstWrite(httpConduit.java:1241)   at 
org.apache.cxf.transport.http.URLConnectionhttpConduit$URLConnectionWrappedOutputStream.onFirstWrite(URLConnectionhttpConduit.java:195)
    at 
org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:47)
    at 
org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)    at 
org.apache.cxf.transport.http.httpConduit$WrappedOutputStream.close(httpConduit.java:1295)
    ... 12 more
Exception in thread "main" javax.xml.ws.WebserviceException: Could not send message.
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:146)
    at $Proxy29.getUserInformation(Unknown sourcE)
    at 
org.tempuri.serviceSoap_serviceSoap_Client.main(serviceSoap_serviceSoap_Client.java:78)
Caused by: java.io.IOException: IOException invoking 
myurl/**/**/asmx: The https URL hostname does not 

match the Common Name (CN) on the server certificate in the client's truststore.  Make sure 

server certificate is correct,or to disable this check (NOT recommended for production) set 

the CXF client TLS configuration property "disableCNcheck" to true.
    at sun.reflect.NativeConstructOraccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructOraccessorImpl.newInstance(Unknown sourcE)
    at sun.reflect.DelegaTingConstructOraccessorImpl.newInstance(Unknown sourcE)
    at java.lang.reflect.Constructor.newInstance(Unknown sourcE)
    at 
org.apache.cxf.transport.http.httpConduit$WrappedOutputStream.mapException(httpConduit.java:1338)
    at 
org.apache.cxf.transport.http.httpConduit$WrappedOutputStream.close(httpConduit.java:1322)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.httpConduit.close(httpConduit.java:627)
    at 
org.apache.cxf.interceptor.messageSenderInterceptor$messageSenderEndingInterceptor.handlemessage(messageSenderInterceptor.java:62)
    at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
    ... 2 more
Caused by: java.io.IOException: The https URL hostname does not match the Common Name (CN) 
on the server certificate in the client's truststore.  Make sure server certificate is 
correct,or to disable this check (NOT recommended for production) set the CXF client TLS 
configuration property "disableCNcheck" to true.
    at 
org.apache.cxf.transport.http.httpConduit$WrappedOutputStream.onFirstWrite(httpConduit.java:1241)
    at 
org.apache.cxf.transport.http.URLConnectionhttpConduit$URLConnectionWrappedOutputStream.onFirstWrite(URLConnectionhttpConduit.java:195)
    at 
org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:47)
    at 
org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)    at 
org.apache.cxf.transport.http.httpConduit$WrappedOutputStream.close(httpConduit.java:1295)

有人可以帮我弄这个吗.提前致谢…

解决方法

根据您必须选择的CXF客户端的类型.如果您具有基于Spring的客户端配置,则必须向http:conduit配置添加属性:
<http:conduit name="{http://apache.org/Hello_world_soap_http}SoapPort.http-conduit">
    <http:tlsClientParameters disableCNcheck="true">
       <!-- other tls configuration parameters,like trustManagers -->
    </http:tlsClientParameters>
</http:conduit>

name必须匹配WSDL中的命名空间和端口名称.

如果您使用progrAMMaticaly创建客户端,请使用以下代码:

httpConduit httpConduit = (httpConduit) ClientProxy.getClient(port).getConduit();

TLSClientParameters tlsCP = new TLSClientParameters();
// other TLS/SSL configuration like setTing up TrustManagers
tlsCP.setDisableCNcheck(true);
httpConduit.setTlsClientParameters(tlsCp);

其中port是您调用的实际客户端代理.

这两个选项都可以在CXF example that I modified here中找到

BTW.在生产环境中使用此属性存在真正的威胁,因此请虑为生产服务器发布具有正确CN的新证书,而不是依赖于此hack.

大佬总结

以上是大佬教程为你收集整理的web-services – java webservice客户端中的握手异常全部内容,希望文章能够帮你解决web-services – java webservice客户端中的握手异常所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。