Import SSL Certificate into Java keystore
We will get the javax.net.ssl.SSLHandshakeException error when we try to access HTTPS urls in java. To avoid these certificate issues, we need to import the SSL Certificate into JVM
Caused by: 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
- Download the Certificate
- Import the Certificate into JVM using keytool
Download the certificate:
- Open the URL in chrome browser: https://services.gradle.org
- Press F12 to access developer tools
- Go to security tab
- Click on View certificate and click on Details tab in the following window.
- Click on “Copy to File” and again click on “Next button”
- Specify the file name by clicking on “Browse” button.
- Now click on finish
Step2: Import the SSL Certificate
JDK provides keytool to import the SSL Certificate
- Open CMD prompt in admin mode and enter “keytool -importcert -help”
- In the above steps, i downloaded the certificate into C:\Users\pokurija\Pictures\javasavvy\gradle.cer path
- Navigate to “C:\Program Files\Java\jre\lib\security” path and give the following command to import the cert.
Hope this helps.