Configure a Java HTTP Client to Accept Self-Signed Certificates: Difference between revisions
Jump to navigation
Jump to search
Line 6: | Line 6: | ||
=Overview= | =Overview= | ||
If a Java client is attempting to connect to a HTTPS server configured with self-signed SSL | If a Java client is attempting to connect to a HTTPS server configured with a self-signed SSL certificate, the Java client will fail with: | ||
... | ... | ||
Line 12: | Line 12: | ||
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target | sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target | ||
This article provides a solution to this problem. The solution consist in obtaining the HTTPS server's public key, importing it into a local truststore and configuring the Java client to use the local truststore. | This article provides a solution to this problem. The solution consist in obtaining the HTTPS server's public key, importing it into a local truststore and configuring the Java client to use the local truststore. | ||
=Procedure= | =Procedure= |
Revision as of 10:31, 9 December 2017
Internal
Overview
If a Java client is attempting to connect to a HTTPS server configured with a self-signed SSL certificate, the Java client will fail with:
... sun.security.validator.ValidatorException: PKIX path building failed: \ sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
This article provides a solution to this problem. The solution consist in obtaining the HTTPS server's public key, importing it into a local truststore and configuring the Java client to use the local truststore.
Procedure
Obtain the HTTPS Server's Certificate
Use openssl s_client to obtain the server's certificate as described here. The response will include the server's certificate in PEM format.
Save it locally in a server-cert.pem file.