javax. net. ssl. SSLHandshakeException:sun. security. validator. ValidatorException
Previously, I could successfully send a request to the web service and receive a response, but it now returns the following exception Based on other answers, I need to update my certificate, but I need to know why I receive this exception now Another problem is that I can find my java_ Home, but I can't renew the certificate
Exceptions:
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();
Solution
The problem is that you are trying to communicate with a server whose SSL certificate has expired The reason you get the exception is because the Java SSL code is checking the certificate chain and has noticed the problem The expired SSL certificate is unreliable... And is not trusted by the default certificate validator
Renewal of the certificate depends on the site owner If it's not you, there's nothing you can do but bypass certificate verification... It's harmful to SSL connection security