springboot忽略证书_Java信任所有SSL证书,HTTPS请求抛
错,忽略证书请求。。。
公司⼀个密钥是采⽤ cdn 加载的,是 七⽜ 提供的镜像空间,由沃通提供的2年的免费的 SSL 证书。
错误信息:
PKIX path building failed: sun.path.SunCertPathBuilderException: unable to find valid certification path to
详细错误信息:
javax.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed:
sun.path.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.SSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
at sun.security.adRecord(SSLSocketImpl.java:1016)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
at sun.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
at
sun.www.protocol.t(AbstractDelegateHttpsURLConnection.java:185)
at sun.www.protocol.OutputStream(HttpURLConnection.java:1091)
at sun.www.protocol.OutputStream(HttpsURLConnectionImpl.java:250)
at com.sojson.www.zhanzhang.quest(HTTPNewManager.java:106)
at com.sojson.www.zhanzhang.quest(HttpManager.java:148)
at com.sojson.quest(HTTPRequestIndexController.java:102)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:606)
at org.hod.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.hod.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at
org.springframework.web.hod.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandle
at
org.springframework.web.hod.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingH
at
org.springframework.web.hod.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerA
at
org.springframework.web.hod.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:870)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at at.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:250)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.uteChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.uteChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.ute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
at org.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.tor.CoyoteAdapter.service(CoyoteAdapter.java:442)
at http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)
at AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
at at.util.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at urrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at urrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at at.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed:
sun.path.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
at sun.security.ineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
... 74 more
解决⽅案
⽅案⼀:
下载apache按照要求,把证书上传到服务器上,具体⽅法⾃⾏百度解决,这⾥不做叙述。
⽅案⼆:
添加下⾯的代码和⼯具类,⼯具类在下⾯附件中有,直接下载即可。//省略代码。。。realUrl = new URL(url);
if("https".Protocol())){
SslUtils.ignoreSsl();
}
//省略代码。。。
然后⼯具类SslUtils再附件中下载。即可解决因为没 SSL 证书报错。
Java 信任所有 SSL 证书, HTTPS 请求抛错,忽略证书请求完美解决
附件下载:
备注:点击⽂件名下载,附件源来⾃云端,只能在本站下载。复制下载链接⽆效。
如果本⽂对你有帮助,那么请你赞助我,让我更有激情的写下去,帮助更多的⼈。¥我需要⾛的更远,点击我 赞助。
如果还有疑问,点击我加,为你提供最好的解答。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论