Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java URL连接提供证书路径错误_Java_Ssl_Httpurlconnection - Fatal编程技术网

Java URL连接提供证书路径错误

Java URL连接提供证书路径错误,java,ssl,httpurlconnection,Java,Ssl,Httpurlconnection,我正在尝试连接一个https提供证书错误 javax.net.ssl.SSLHandshakeException: sun.security.validator.validator异常:PKIX路径生成失败: sun.security.provider.certpath.SunCertPathBuilderException:无法 在上找到请求目标的有效证书路径 位于的sun.security.ssl.Alerts.getSSLException(Alerts.java:192) sun.sec

我正在尝试连接一个
https
提供证书错误

javax.net.ssl.SSLHandshakeException: sun.security.validator.validator异常:PKIX路径生成失败: sun.security.provider.certpath.SunCertPathBuilderException:无法 在上找到请求目标的有效证书路径 位于的sun.security.ssl.Alerts.getSSLException(Alerts.java:192) sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1886)位于 sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)位于 sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)位于 server证书(ClientHandshaker.java:1341) 在 processMessage(ClientHandshaker.java:153) 位于sun.security.ssl.Handshaker.processLoop(Handshaker.java:868) sun.security.ssl.Handshaker.process_记录(Handshaker.java:804)位于 sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)位于 sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312) 在 sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339) 在 sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323) 在 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) 在 net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:629) 在 net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1320) 在 net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) 在 net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338) 位于com.poc.TestServlet.doPost(TestServlet.java:75) http.HttpServlet.service(HttpServlet.java:641)位于 http.HttpServlet.service(HttpServlet.java:722)位于 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) 在 org.apache.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.ErrorReportValve.invoke(ErrorReportValve.java:100) 在 org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) 在 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) 在 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) 在 org.apache.tomcat.util.net.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.validator异常: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) 在 server证书(ClientHandshaker.java:1323) ... 又有33宗是由于: sun.security.provider.certpath.SunCertPathBuilderException:无法 在上找到请求目标的有效证书路径 SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196) 位于java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268) 在 sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380) ... 39多


连接是简单的https连接

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

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

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

“cacerts”的默认密码是
changeit

尝试Hi谢谢您的回复,但您能否在Windows中提供解决方案对不起,我不使用Windows,所以我不知道如何操作。也许这可以帮助你: