javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23322676/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException
提问by J888
Previously, I could successfully send request to a web service and receive response but it now returns the following exception. Based on other answers I need to renew the certificate but I need to know why I am receiving this exception now. The other issue is that, I could find the address of my java_home but I can not renew the certificate.
以前,我可以成功地向 Web 服务发送请求并接收响应,但它现在返回以下异常。根据其他答案,我需要更新证书,但我需要知道为什么我现在收到此异常。另一个问题是,我可以找到我的 java_home 的地址,但我无法更新证书。
Exception:
例外:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed
Code
代码
URI uri = new URI("https", "xml.example.com", "/service/ServiceRequest.do",
"serverName=www.example.com&xml="
...
+" ", null);
URL page = uri.toURL();
HttpsURLConnection conn = (HttpsURLConnection) page.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.connect();
回答by Stephen C
The problem is that you are trying to talk to a server whose SSL Certificate has expired. The reason you are getting the exception is because the Java SSL code is checking the certificate chain, and has noticed the problem. A SSL certificate that has expired is not trustworthy ... and is not trusted by the default certificate validator.
问题是您正在尝试与 SSL 证书已过期的服务器通信。您收到异常的原因是 Java SSL 代码正在检查证书链,并且已经注意到问题。已过期的 SSL 证书不可信……并且不受默认证书验证器的信任。
I can not renew the certificate ...
我不能更新证书...
Renewing the certificate is up to the owner of the website. If that is not you, then there is nothing you can do ... apart from bypassing validation of the certificate, which is bad for SSL connection security.
更新证书取决于网站的所有者。如果那不是您,那么您无能为力……除了绕过对 SSL 连接安全性不利的证书验证。