- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经为应用程序配置了 keystore 和信任库。我尝试使用 WebService 模板通过 HTTPS 来使用 Web 服务,这是我的配置
public GetCountryResponse find() throws MalformedURLException, GeneralSecurityException, IOException {
GetCountryRequest request = new GetCountryRequest();
request.setName("Spain");
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
LayeredConnectionSocketFactory sslSocketFactory = null;
try {
sslSocketFactory = new SSLConnectionSocketFactory(SSLContext.getDefault(),
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
} catch (NoSuchAlgorithmException e) {
}
KeyStore keyStore = KeyStore.getInstance("PKCS12");
FileInputStream instream = new FileInputStream(new File("C:\\client.p12"));
try {
keyStore.load(instream, "password".toCharArray());
} finally {
instream.close();
}
// Trust own CA and all self-signed certs
SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "password".toCharArray())
// .loadTrustMaterial(trustStore, new TrustSelfSignedStrategy())
.build();
// Allow TLSv1 protocol only
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[] { "TLSv1" }, null,
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); // TODO
HttpClient httpclient = HttpClients.custom()
.setHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER) // TODO
.setSSLSocketFactory(sslsf).addInterceptorFirst(new ContentRemover()).build();
HttpComponentsMessageSender messageSender = new HttpComponentsMessageSender(httpclient);
WebServiceMessageSender sender = messageSender;
WebServiceTemplate webServiceTemplate = getWebServiceTemplate();
webServiceTemplate.setMessageSender(sender);
GetCountryResponse response = (GetCountryResponse) webServiceTemplate.marshalSendAndReceive(
"https://localhost:8443/ws/countries.wsdl", request,
new SoapActionCallback("https://localhost:8443/ws/"));
return response;
}
我收到以下错误
%% Invalidated: [Session-4, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384]
http-nio-8444-exec-2, SEND TLSv1.2 ALERT: fatal, description = certificate_unknown
http-nio-8444-exec-2, WRITE: TLSv1.2 Alert, length = 2
http-nio-8444-exec-2, called closeSocket()
http-nio-8444-exec-2, handling exception: 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
14:38:01.080 [http-nio-8444-exec-2] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-1: Shutdown connection
http-nio-8444-exec-2, called close()
http-nio-8444-exec-2, called closeInternal(true)
14:38:01.080 [http-nio-8444-exec-2] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection discarded
14:38:01.080 [http-nio-8444-exec-2] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-1: Close connection
14:38:01.080 [http-nio-8444-exec-2] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 1][route: {s}->https://localhost:8443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
14:38:01.080 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver - Resolving exception from handler [public com.covenant.app.wsdl.GetCountryResponse com.covenant.app.controllers.DealController.findAllDeals()]: org.springframework.ws.client.WebServiceIOException: I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is 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
14:38:01.080 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver - Invoking @ExceptionHandler method: public org.springframework.http.ResponseEntity<java.lang.String> com.covenant.app.controllers.DealController.errorHandler(java.lang.Exception)
14:38:01 [http-nio-8444-exec-2] DealController - I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is 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
org.springframework.ws.client.WebServiceIOException: I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is 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.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:561)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
at com.covenant.app.services.WeatherClient.find(WeatherClient.java:90)
at com.covenant.app.controllers.DealController.findAllDeals(DealController.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1757)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1716)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
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(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:262)
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:118)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:314)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:357)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:218)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:194)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:85)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at org.springframework.ws.transport.http.HttpComponentsConnection.onSendAfterWrite(HttpComponentsConnection.java:121)
at org.springframework.ws.transport.AbstractWebServiceConnection.send(AbstractWebServiceConnection.java:48)
at org.springframework.ws.client.core.WebServiceTemplate.sendRequest(WebServiceTemplate.java:658)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:606)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
... 41 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(PKIXValidator.java:387)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491)
... 65 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:146)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
... 71 more
14:38:01.094 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdviceChain - Invoking ResponseBodyAdvice chain for body=I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is 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
14:38:01.094 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdviceChain - After ResponseBodyAdvice chain body=I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is 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
http-nio-8444-exec-2, WRITE: TLSv1.2 Application Data, length = 669
14:38:01.096 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor - Written [I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is 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] as "text/html" using [org.springframework.http.converter.StringHttpMessageConverter@65423e86]
14:38:01.096 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
14:38:01.096 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request
http-nio-8444-exec-2, called closeOutbound()
http-nio-8444-exec-2, closeOutboundInternal()
http-nio-8444-exec-2, SEND TLSv1.2 ALERT: warning, description = close_notify
http-nio-8444-exec-2, WRITE: TLSv1.2 Alert, length = 26
http-nio-8444-exec-4, called closeOutbound()
http-nio-8444-exec-4, closeOutboundInternal()
在浏览器中出现以下错误
I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is 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
我在互联网上搜索解决方案,所以我尝试使用
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[] { "TLSv1" }, null,
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); // TODO
HttpClient httpclient = HttpClients.custom()
.setHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER) // TODO
.setSSLSocketFactory(sslsf).build();
HttpComponentsMessageSender messageSender = new HttpComponentsMessageSender(httpclient);
WebServiceMessageSender sender = messageSender;
WebServiceTemplate webServiceTemplate = getWebServiceTemplate();
webServiceTemplate.setMessageSender(sender);
但是然后我得到以下异常
trustStore is: C:\trustore.jks
trustStore type is : jks
trustStore provider is :
init truststore
adding as trusted cert:
Subject: EMAILADDRESS=briantauro7@gmail.com, CN=localhost, OU=localhost, O=ITCOVENANT, L=Coimbatore, ST=Tamil Badu, C=IN
Issuer: EMAILADDRESS=briantauro7@gmail.com, CN=localhost, OU=localhost, O=ITCOVENANT, L=Coimbatore, ST=Tamil Badu, C=IN
Algorithm: RSA; Serial number: 0x9f141ecadb1b5892
Valid from Mon Jun 06 22:09:30 IST 2016 until Tue Jun 06 22:09:30 IST 2017
trigger seeding of SecureRandom
done seeding SecureRandom
00:00:38.964 [http-nio-8444-exec-2] DEBUG org.springframework.ws.client.core.WebServiceTemplate - Opening [org.springframework.ws.transport.http.HttpComponentsConnection@47cea62b] to [https://localhost:8443/ws/countries.wsdl]
00:00:39.032 [http-nio-8444-exec-2] DEBUG org.springframework.ws.client.MessageTracing.sent - Sent request [SaajSoapMessage {http://spring.io/guides/gs-producing-web-service}getCountryRequest]
00:00:39.085 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver - Resolving exception from handler [public com.covenant.app.wsdl.GetCountryResponse com.covenant.app.controllers.DealController.findAllDeals() throws java.net.MalformedURLException,java.security.GeneralSecurityException,java.io.IOException]: org.springframework.ws.client.WebServiceIOException: I/O error: null; nested exception is org.apache.http.client.ClientProtocolException
00:00:39.089 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver - Invoking @ExceptionHandler method: public org.springframework.http.ResponseEntity<java.lang.String> com.covenant.app.controllers.DealController.errorHandler(java.lang.Exception)
00:00:39 [http-nio-8444-exec-2] DealController - I/O error: null; nested exception is org.apache.http.client.ClientProtocolException
org.springframework.ws.client.WebServiceIOException: I/O error: null; nested exception is org.apache.http.client.ClientProtocolException
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:561)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
at com.covenant.app.services.WeatherClient.find(WeatherClient.java:98)
at com.covenant.app.controllers.DealController.findAllDeals(DealController.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1757)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1716)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:188)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at org.springframework.ws.transport.http.HttpComponentsConnection.onSendAfterWrite(HttpComponentsConnection.java:121)
at org.springframework.ws.transport.AbstractWebServiceConnection.send(AbstractWebServiceConnection.java:48)
at org.springframework.ws.client.core.WebServiceTemplate.sendRequest(WebServiceTemplate.java:658)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:606)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
... 41 more
Caused by: org.apache.http.ProtocolException: Content-Length header already present
at org.apache.http.protocol.RequestContent.process(RequestContent.java:96)
at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:132)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:192)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:85)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
... 49 more
00:00:39.111 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdviceChain - Invoking ResponseBodyAdvice chain for body=I/O error: null; nested exception is org.apache.http.client.ClientProtocolException
00:00:39.111 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdviceChain - After ResponseBodyAdvice chain body=I/O error: null; nested exception is org.apache.http.client.ClientProtocolException
http-nio-8444-exec-2, WRITE: TLSv1.2 Application Data, length = 303
00:00:39.115 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor - Written [I/O error: null; nested exception is org.apache.http.client.ClientProtocolException] as "text/html" using [org.springframework.http.converter.StringHttpMessageConverter@4ec86e91]
00:00:39.115 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
00:00:39.115 [http-nio-8444-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request
http-nio-8444-exec-2, called closeOutbound()
http-nio-8444-exec-2, closeOutboundInternal()
http-nio-8444-exec-2, SEND TLSv1.2 ALERT: warning, description = close_notify
http-nio-8444-exec-2, WRITE: TLSv1.2 Alert, length = 26
http-nio-8444-exec-5, called closeOutbound()
http-nio-8444-exec-5, closeOutboundInternal()
http-nio-8444-exec-5, SEND TLSv1.2 ALERT: warning, description = close_notify
http-nio-8444-exec-5, WRITE: TLSv1.2 Alert, length = 26
http-nio-8444-exec-4, called closeOutbound()
http-nio-8444-exec-4, closeOutboundInternal()
http-nio-8444-exec-4, SEND TLSv1.2 ALERT: warning, description = close_notify
http-nio-8444-exec-4, WRITE: TLSv1.2 Alert, length = 26
http-nio-8444-exec-9, called closeOutbound()
http-nio-8444-exec-9, closeOutboundInternal()
http-nio-8444-exec-9, SEND TLSv1.2 ALERT: warning, description = close_notify
http-nio-8444-exec-9, WRITE: TLSv1.2 Alert, length = 26
如果我将此代码与
一起添加HttpClient httpclient = HttpClients.custom()
.setHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER) // TODO
.setSSLSocketFactory(sslsf).addInterceptorFirst(new ContentRemover()).build();
内容删除器类:
public class ContentRemover implements HttpRequestInterceptor{
@Override
public void process(HttpRequest request, HttpContext context)
throws HttpException, IOException {
if (request instanceof HttpEntityEnclosingRequest) {
System.out.println("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww");
if (request.containsHeader(HTTP.TRANSFER_ENCODING)) {
request.removeHeaders(HTTP.TRANSFER_ENCODING);
}
if (request.containsHeader(HTTP.CONTENT_LEN)) {
request.removeHeaders(HTTP.CONTENT_LEN);
}
}
}
}
然后我再次遇到相同的错误
I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is 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
请帮忙。如果有任何链接或示例代码,请更新
最佳答案
我终于找到了解决方案,我只需在运行 tomcat 7 时将 keystore 和 trustore 指定为 vm 参数即可开始工作
-Djavax.net.ssl.keyStoreType=jks
-Djavax.net.ssl.keyStore="C:\keystore.jks"
-Djavax.net.ssl.keyStorePassword=password
-Djavax.net.ssl.trustStore="C:\trustore.jks"
-Djavax.net.ssl.trustStorePassword=password
-Djavax.net.debug=SSL
关于java - 如何配置 WebServiceTemplate 以在 HTTPS 下向服务器发送 SOAP 请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37675288/
我正在尝试使用 Spring-WS 编写我的第一个客户端,并且对一些基础知识感到有些困惑。我需要在 header 中插入一个 SAML token ,并且我注意到 WebServiceTemplate
我使用mockito 3如下: Mockito.when(webServiceTemplate.marshalSendAndReceive(Mockito.anyString(),
看起来 Spring 的 WebServiceTemplate 忽略了连接超时的设置。那,或者我误解了连接超时。 这是我的配置: @Bean public SoapTemplate soapTempl
我有一个 SOAP 网络服务端点 url(比方说:“EP1”),我们只能通过代理服务器连接它。 我们正在使用 org.springframework.ws.client.core.WebService
我正在尝试测试当前使用基本身份验证保护的 Spring Web 服务。对于这些测试,我使用 Spring 的 WebServiceTemplate 编写了一个 Web 服务客户端。类。 当我将模板的
我使用 spring ws 模板创建了一个 Web 服务客户端。这按 http 协议(protocol)的预期工作。现在我想让它与 https 一起使用。我有相关的客户端 key 存储(jks 文件)
我正在将 Spring-WS 与 JAXB 结合使用。 有下一段代码: WebServiceTemplate template = (WebServiceTemplate) ctx.getBean("
我在 Spring Boot 中使用 WebServiceTemplate 并使用 marshalSendAndReceive 调用目标服务。 如何在请求中设置自定义 HTTP header ? 最佳
我正在尝试找出为 Spring 的 WebService 模板类编写单元测试的最佳方法。我要做的是检查以确保我为我的客户生成的每个请求/响应类型正确连接了这些类。我还想确保如果返回异常,则异常会得到正
我正在使用 org.springframework.ws.client.core.WebServiceTemplate用于进行 Web 服务调用。如何配置通话超时。 最佳答案 如果您使用的是 Spri
我必须使用 Spring WS 实现一个 Web 服务客户端。 我已阅读 http://static.springsource.org/spring-ws/site/reference/html/cl
我尝试在发送文档请求之前对其进行签名,但是在检索请求文档时通过Document doc = soapMessage.getSOAPPart().getEnvelope().getOwnerDocume
我使用 Spring WebServiceTemplate 类来创建和实例化 JAXB 生成的类的请求对象,使用它调用 marshallSendAndReceive 方法,然后将响应对象转换为 JAX
我正在使用 string-ws 创建 Web 服务客户端并从 Web 服务获取数据。我使用 org.jvnet.jaxb2.maven2:maven-jaxb2-plugin 来生成 java 类。下
有没有办法以编程方式设置 Spring 的 WebServiceTemplate 的超时?我看过有关通过应用程序上下文配置文件中的消息发送器设置它的旧文章。但在我们的项目中,这些对象是通过代码创建的,
我有一个调用现有网络服务的类。我的类正确处理有效结果以及 Web 服务生成的错误字符串。对 Web 服务的基本调用如下所示(尽管已简化)。 public String callWebService(f
我知道可以使用 Eclipse TCP/IP 监视来跟踪 SOAP 消息。我试过了,但它无法监控我的本地主机。 TCP/IP 不在其控制台中显示本地主机。 我可以通过http://localhost:
我正在用 spring 开发一个 SOAP 网络服务客户端。 我正在使用 webServiceTemplate 如何指定我使用哪种版本的 SOAP ? 我可以看到它默认使用的是soap 1.1。 我想
我正在尝试向 SOAP 网络服务发送请求。我读了this tutorial并准备了以下代码。但是,我将向多个 SOAP Web 服务发送不同的请求,而本教程只关注一个请求。如何使用 Webservic
是否可以使用 java keystore 配置 WebServiceTemplate? 编辑 我正在寻找一种在spring config中配置 keystore 位置的方法 最佳答案 我在六年后发布这
我是一名优秀的程序员,十分优秀!