0
我需要使用下面的方法从KeyStore类:转换的关键对象专用密钥
public Key getPrivateKey(String alias)
但在最后,我需要专用密钥对象,而不是重点。我如何将Key对象转换为PrivateKey? 谢谢!
我需要使用下面的方法从KeyStore类:转换的关键对象专用密钥
public Key getPrivateKey(String alias)
但在最后,我需要专用密钥对象,而不是重点。我如何将Key对象转换为PrivateKey? 谢谢!
后,您从您的密钥存储 密钥的密钥创建密钥对,然后得到一对密钥的酒吧和私法重点如下:
Key prvkey = keyStore.getKey(_alias,_keypass.toCharArray());
PublicKey pubkey = certificate.getPublicKey();
KeyPair keypair = new KeyPair(pubkey, (PrivateKey)prvkey);
PrivateKey privKewy = keypair.getPrivate();
//get keystore
//jks for type "JKS",
//.p12 or .pfx for type "PKCS12"
//specification name is PKCS#12, but the # is not used in the Java keystore type name
KeyStore keystore = KeyStore.getInstance("pkcs12");
//load keystore - is FileImputStream to location of your pfx/jks file
keystore.load(is, password);
//get private key
PrivateKey privateKey = (PrivateKey)keystore.getKey(alias, password);
AFAIK它的安全投关键专用密钥。 – 2014-09-24 19:11:17