我申请了证书后,导出了证书的私钥。我该怎么读入?
//下面这段代码只能 读取用 new ObjectOutputStream(private_file_out);生成的私钥。try{
private_file_in = new FileInputStream(path1);
private_object_in = new ObjectInputStream(private_file_in);
rsa_private = (RSAPrivateKey)private_object_in.readObject();
private_file_in.close();
}catch(Exception e){
System.out.println(e);}该怎么读入Windows2003里证书管理导出的私钥?而且私钥还有密码
//下面这段代码只能 读取用 new ObjectOutputStream(private_file_out);生成的私钥。try{
private_file_in = new FileInputStream(path1);
private_object_in = new ObjectInputStream(private_file_in);
rsa_private = (RSAPrivateKey)private_object_in.readObject();
private_file_in.close();
}catch(Exception e){
System.out.println(e);}该怎么读入Windows2003里证书管理导出的私钥?而且私钥还有密码
import java.security.KeyStore;
import java.security.PrivateKey;
String file = "<your file>";
KeyStore ks = KeyStore.getInstance("PKCS12");
FileInputStream fis = new FileInputStream(file);
char[] pwd = {'1', '2', '3'}; // your password
ks.load(fis, pwd);
String alias = (String) ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, pwd);
System.out.println(key);