Posts

Showing posts from April, 2016

Error : java.lang.SecurityException: Can not initialize cryptographic mechanism

During certificate import using InstallCert.Java, I faced this issue. This can cause if you don't have required restriction policy file or the key size is greater than the once deployed by Java by default which is 128 bit. 

This can be solved by downloading the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files from Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files  and copying them in your JRE.

Error : unable to find valid certification path to requested target

I was trying to run Java application, which was using REST Template to implement rest client. The application was connecting to REST service (REST API's) over SSL. The certificate used for SSL was self signed certificate.

The self signed certificate was causing error "unable to find valid certification path to requested target" every time I tried to connect to REST Service. 

In order to resolve this error, I had to add the certificate to the JVM key store. I tried multiple steps, even corrupted the keystore but finally was able to run application successfully. 

You would need InstallCert.Java to successfully import the certificate which can be found at InstallCert.Java

Above git repo has ReadMe which details out all steps required for importing the certificate. 
If you happen to corrupt the keystore you can follow below link to restore it.

http://architecturalatrocities.com/post/19073788679/fixing-the-trustanchors-problem-when-running