rogerxu / rogerxu.github.io

Roger Xu's Blog
3 stars 2 forks source link

Java Import Cert #219

Open rogerxu opened 6 years ago

rogerxu commented 6 years ago

SunCertPathBuilderException: unable to find valid certification path to requested target

No more 'unable to find valid certification path to requested target' | Natural Order Development

unable to find valid certification path to requested target (GC - Garbage Collection? GotCha?)

$ java InstallCert ecc.fedora.redhat.com
Enter certificate to add to trusted keystore or 'q' to quit: [1]
Added certificate to keystore 'jssecacerts' using alias
'ecc.fedora.redhat.com-1'

It displayed the complete certificate and then added it to a Java KeyStore 'jssecacerts' in the current directory. To use it in your program, either configure JSSE to use it as its trust store (as explained in the documentation) or copy it into your $JAVA_HOME/jre/lib/security directory. If you want all Java applications to recognize the certificate as trusted and not just JSSE, you could also overwrite the cacerts file in that directory.

Add CA Certificate

Add a certificate to the Java CA store | Microsoft Azure

List CA certificates

$ cd %JAVA_HOME%/jre/lib/security
$ keytool -list -keystore cacerts

You'll be prompted for the store password. The default password is changeit.

Import CA certificate

$ keytool -importcert -trustcacerts -alias equifaxsecureca -file some/path/Equifax_Secure_Certificate_Authority.cer -keystore %JAVA_HOME%/jre/lib/security/cacerts

Import Certificate

Import the Certificate as a Trusted Certificate (The Java™ Tutorials > Security Features in Java SE > Exchanging Files)

$ keytool -import -alias myserver -file server.cer -keystore cacerts