💥 ERROR1: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

This occurs when Java doesn’t trust the SSL certificate of the site/server you're connecting to.
Issue is Fixed after Importing the Certificate into the Java Truststore.


✅ Solution

Step 1: Export the Certificate


Step 2: Navigate to Java Security Folder

Open PowerShell as Administrator and run:

cd 'C:\Program Files\Java\jdk-17.0.3.1\lib\security' 


Step 3: Import the Certificate into Java Truststore

Run the following command in the same PowerShell window:

keytool -importcert -file 'C:\Users\Administrator\Downloads\emSign Root CA - G1.crt' -keystore .\cacerts -alias 'cn_emsign_root_ca__g1,o_emudhra_technologies_limited,ou_emsign_pki,c_in [jdk]' 

When prompted for a password, enter: changeit

✅ Confirm the import by typing yes when prompted.


🔄 Step 4: Restart Java-Based Application

Restart the Java application — it should now trust the certificate.