Adding Trusted Certificates for Java on Windows
How to add a trusted CA (Certificate Authority) certificate into Java default keystore on Windows? My Java application failed because the server certificate is signed by a new CA.
If you are getting the "PKIX path building failed" error with this message: "sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target", and you decide to add the missing top certificate into Java default trusted keystore, you can try:
1. Use the "keytool -importcert" command to add the certificate in a command line window to the system level trusted certificate keystore "cacerts" file. See the command example below:
C:\Users\fyicenter>"\Program Files\java\jre7\bin\keytool" -importcert -keystore "\Program Files\java\jre7\lib\security\cacerts" -storepass changeit -file my_cert.pem -alias my_cert -noprompt
But if you don't system admin permission, will get an error: "keytool error: java.io.FileNotFoundException: \Program Files\java\jre7\lib\security\cacerts (Access is denied)"
2. Use the "keytool -importcert" command to add the certificate in a command line window to the user level trusted certificate keystore "trusted.certs" file: See the command example below:
C:\Users\fyicenter>"\Program Files\java\jre7\bin\keytool" -importcert -keystore "\Users\fyicenter\AppData\LocalLow\sun\Java\Deployment\security \trusted.certs" -storepass "" -file my_cert.pem -alias my_cert -noprompt
If it works, you will see this messag: "Certificate was added to keystore".
3. Try "Java Control Panel" GUI tool, if you don't like the "keytool" command line. "Java Control Panel" is located in Windows "Control Panel" under the name "Java". Click "Security" tab, then "Certificates..." button, then "User" tab with "Trusted Certificates" selected.
2012-07-21, 41793👍, 3💬
Certificate summary - Owner: DigiCert SHA2 Secure Server CA, DigiCert Inc, US Issuer: DigiCert Globa...
How to print out text information from a certificate using OpenSSL "x509" command? I want to see the...
Certificate Summary: Subject: VeriSign Class 3 Public Primary Certification Authority - G3 Issuer: V...
How to list all certificates on my Android device? I want to know what's in the "System" store and w...
Certificate Summary: Subject: SRCA Issuer: SRCA Expiration: 2029-05-20 06:56:00 UTC Key Identifier: ...