这是我的计划。我收到错误"错误打开密钥文件"。请帮助我在哪里出错。
import java.io.FileInputStream;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.PrivateKey;
import java.util.Base64;
public class ExtractionClass {
public static void main(String args[]) {
String p12Password = "PassWord";
try{
FileInputStream file = new FileInputStream("C:/Users/Aarti_Jangid/Desktop/p12/certChain.p12");
System.out.println("FILE "+ file);
KeyStore keystore = KeyStore.getInstance("PKCS12", "SunJSSE");
keystore.load(file, p12Password.toCharArray());
String alias = keystore.aliases().nextElement();
PrivateKey key = (PrivateKey)keystore.getKey(alias, p12Password.toCharArray());
System.out.println(Base64.getEncoder().encodeToString(key.getEncoded()));
} catch(KeyStoreException kse) {
kse.printStackTrace();
System.err.println("Error getting the key");
} catch (Exception e) {
System.err.println("Error opening the key file");
e.printStackTrace();
}
}
}
答案 0 :(得分:0)
我假设您的堆栈跟踪是:
Error opening registry key 'C:/Users/Aarti_Jangid/Desktop/p12/certChain.p12'
Error: could not find Java.dll
Error: could not find Java 2 Runtime Environment