问题描述
我要对我使用密钥工具和以下命令创建的一对RSA密钥签名的文件进行签名:
I want to sign a file i created using a pair of RSA keys I created using key tool and the following command:
keytool -genkeypair -alias key -keyalg RSA -keysize 2048 -siglg SHA256withRSA -validity 365 -keystore keystore.jks
我想初始化我的签名对象,所以我尝试了这个:
I want to initialize my Signature object so I tried this:
PrivateKey privateKey = (PrivateKey) keyStore.getKey(PRIVATE_KEY_ALIAS,privateKeyPassword);
Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM);
signature.initSign(privateKey);
但是我得到了这个例外:没有安装的提供程序支持此密钥:sun.security.rsa.RSAPrivateCrtKeyImpl
But I got this exception:No installed provider supports this key: sun.security.rsa.RSAPrivateCrtKeyImpl
感谢任何帮助!
推荐答案
您不能将 SHA1withDSA
与RSA密钥一起使用.将签名算法更改为 SHA1withRSA
或生成DSA密钥instea
You can't use SHA1withDSA
with an RSA key. Change signature algorithm to SHA1withRSA
or generate a DSA key instea
这篇关于JAVA签名对象-没有安装的提供程序支持此密钥:sun.security.rsa.RSAPrivateCrtKeyImpl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!