首页 文章

URL连接给出证书路径错误

提问于
浏览
0

Wile我试图连接 https 给出证书错误

javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法在sun.security.ssl.Alerts找到所请求目标的有效证书路径 . get.SLException(Alerts.java:192)at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1886)at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)at sun.security.ssl.Handshaker位于sun.security.ssl的sun.security.ssl.ClientHandshaker.serverMertage(ClientHandshaker.java:1341)sun.security.ssl的sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153).fatalSE(Handshaker.java:270) . Handshaker.processLoop(Handshaker.java:868)at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)at sun.security.ssl.SSLSocketImpl.readRecord(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)在sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:515)在sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.setProxiedClient (AbstractDelegateHttpsURLConnection.java:142)在sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.setProxiedClient(AbstractDelegateHttpsURLConnection.java:118)在sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:629)在sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1320)在java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)在sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode( HttpsURLConnectionImpl.java:338)在com.poc.TestServlet.doPost(TestServlet.java:75)在javax.servlet.http.HttpServlet.service(HttpServlet.java:641)在javax.servlet.http.HttpServlet.service(HttpServlet的.java:722)org.apache.catalina.core.ApplicationFilterChain.internalDoFilte R(ApplicationFilterChain.java:304)处org.apache在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) .catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :164)org.apache.catalina.valves.Error.ReportValve.invoke(ErrorReportValve.java:100)org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)org.apache.catalina.core . org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)上的StandardEngineValve.invoke(StandardEngineValve.java:118)org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)at org org.apache.tomcat.util.n上的.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:188) et.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:302)在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)在java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615)在java.lang.Thread.run(Thread.java:722)产生的原因:sun.security.validator.ValidatorException:PKIX路径建设失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到有效的认证路径请求的目标在sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)在sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)在sun.security.validator.Validator.validate(Validator.java:260 )在sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)在sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)在sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java: 126)at sun.security.ssl.ClientHandshaker.serverCertificate(ClientH sun.security.provider.certpath.SunCertPathBuilderException:andshaker.java:1323)... 33多个致无法在sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java找到有效的认证路径请求的目标: 196)at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)... 39更多

连接是简单的https连接

1 回答

  • 0

    您必须将HTTPS证书放入JVM . 要从HTTPS获取证书,请浏览浏览器,然后单击地址栏上的“锁定”徽标 . 您应该能够导出证书 .

    Linux解决方案:在 $JAVA_HOME/jre/lib/security 中,使用此命令:

    sudo keytool -import -alias keyName -file /[pathForYourKey]/keyName.cert -keystore cacerts
    

    "cacerts"的默认密码是 changeit .

相关问题