JAVA Signature Object - None of the installed providers support this key: sun.security.rsa.RSAPrivateCrtKeyImpl

I want to sign a file created using the RSA key pair created using the key tool and the following command:

keytool -genkeypair -alias key -keyalg RSA -keysize 2048 -sigalg SHA256withRSA -validity 365 -keystore keystore.jks

I want to initialize a Signature object, so I tried this:

 PrivateKey privateKey = (PrivateKey) keyStore.getKey(PRIVATE_KEY_ALIAS,privateKeyPassword); Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM); signature.initSign(privateKey); 

But I got this exception:
No installed provider supports this key: sun.security.rsa.RSAPrivateCrtKeyImpl

Appreciate any help!

+5
source share
1 answer

You cannot use SHA1withDSA with the RSA key. Change the signature algorithm to SHA1withRSA or create a DSA key key

+6
source

Source: https://habr.com/ru/post/1262497/


All Articles