Caused by: java.security.UnrecoverableKeyException: Cannot recover key

后端 未结 5 828
名媛妹妹
名媛妹妹 2020-11-28 23:03

I am supplied with a jks keystore named ABCC_client.store. When I import this keystore to cacerts and try connecting it says No such Algorithm error. PFA the stacktrace

相关标签:
5条回答
  • 2020-11-28 23:32

    In order to not have the Cannot recover key exception, I had to apply the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files to the installation of Java that was running my application. Version 8 of those files can be found here or the latest version should be listed on this page. The download includes a file that explains how to apply the policy files.


    Since JDK 8u151 it isn't necessary to add policy files. Instead the JCE jurisdiction policy files are controlled by a Security property called crypto.policy. Setting that to unlimited with allow unlimited cryptography to be used by the JDK. As the release notes linked to above state, it can be set by Security.setProperty() or via the java.security file. The java.security file could also be appended to by adding -Djava.security.properties=my_security.properties to the command to start the program as detailed here.


    Since JDK 8u161 unlimited cryptography is enabled by default.

    0 讨论(0)
  • 2020-11-28 23:35

    I had the same error when we imported a key into a keystore that was build using a 64bit OpenSSL Version. When we followed the same procedure to import the key into a keystore that was build using a 32 bit OpenSSL version everything went fine.

    0 讨论(0)
  • 2020-11-28 23:47

    If using Tomcat 6 and earlier, make sure the keystore password and the key password are same. If using Tomcat 7 and later, make sure they are the same or that the key password is specified in the server.xml file.

    0 讨论(0)
  • 2020-11-28 23:57

    The private key password defined in your app/config is incorrect. First try verifying the the private key password by changing to another one as follows:

    keytool -keypasswd -new changeit -keystore cacerts -storepass changeit -alias someapp -keypass password
    

    The above example changes the password from password to changeit. This command will succeed if the private key password was password.

    0 讨论(0)
  • 2020-11-28 23:59

    Check if password you are using is correct one by running below command

    keytool -keypasswd -new temp123 -keystore awsdemo-keystore.jks -storepass temp123 -alias movie-service -keypass changeit
    

    If you are getting below error then your password is wrong

    keytool error: java.security.UnrecoverableKeyException: Cannot recover key
    
    0 讨论(0)
提交回复
热议问题