3

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.

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();
J888
  • 1,944
  • 8
  • 42
  • 76

1 Answers1

8

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.

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • all right thank, I thought something is wrong with me. My view is based on http://stackoverflow.com/questions/9619030/resolving-javax-net-ssl-sslhandshakeexception-sun-security-validator-validatore – J888 Apr 27 '14 at 12:45
  • That Q&A is addressing a different SSL problem. That server is presenting a certificate that is probably valid. However, the server is not also presenting the root and intermediate certificates as well. (Or it is presenting them in the wrong order). The end result is that the client is unable to *check* that the certificate is valid. The solutions in that case are different to your case, though one of them does involve the server admin fixing their server to behave *properly*. – Stephen C Oct 02 '18 at 10:55