我试图使用HttpsURLConnection
与网站进行HTTPS连接,然后执行PUT请求。当我尝试从HttpsURLConnection.getOutputStream()
的OutputStreamWriter
,以下异常被抛出:Java HttpsURLConnection SSLHandshakeException
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
页刚刚得到的证书(由StartCom发行) - 做我需要做手工的东西让Java识别证书现在呢?我可以毫不费力地连接到同一网站的其他页面,但他们拥有不同的证书。
谢谢 - 对于有同样问题的其他人,我在本地保存证书,使用'keytool -import ...'命令并添加了'System.setProperty(“javax.net.ssl.trustStore”,“path_to_keystore” );'我的代码。 – caroline
我将不同的命令复制到我的答案中。 – Robert