I want to connect to a https
server which has a self signed certificate
, without modifying my client code.
I know this question has been asked many times, but I couldn't get it to work. Here's what I've done:
Open the
https
server in FirefoxClick on the url info, then more info, then view certificate, then details, then click on export.
Choose the default export type setting (
X.509 Certificate (PEM)
, saved ascertificate.crt
), and save it to disk.Open a command prompt, go to the
java_home
folder used by the client code, which in my case isc:\jdk-7u55-windows-x64\jre\bin
Enter the following command:
keytool -import -v -trustcacerts -alias server-alias -file C:\Downloads\certificate.crt -keystore cacerts.jks -keypass changeit -storepass changeit
I also tried:
keytool -import -v -trustcacerts
-alias server-alias2 -file C:\Downloads\certificate.crt
-keystore keystore.jks
- Restart the client application
After all of this, I still get a SSLHandshakeException
(unable to find valid certification path to requested target).
Full exception in log:
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is 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
I don't know what I did wrong, what else to do or how to debug further.