Вот код для этой программы < /p>
Код: Выделить всё
String jksFile = "C:/EDS/pb_3752709595.jks"; //path to file
String password = "password";//pasword to jks file
String alias=null; // alias
// Load the keystore from file
FileInputStream fis = new FileInputStream(jksFile);
KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(fis, password.toCharArray());
// Get the aliases
Enumeration aliases = keyStore.aliases();
alias = aliases.nextElement();
System.out.println(alias);
Security.addProvider(new BouncyCastleProvider());
keyStore.load(new FileInputStream(jksFile), password.toCharArray());
PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias,password.toCharArray());//error line
Certificate cert = keyStore.getCertificate(alias);
PublicKey publicKey = cert.getPublicKey();
// System.out.println("Private key: " + privateKey);
System.out.println("Public key: " + publicKey);
< /code>
ошибка: < /p>
Exception in thread "main" java.security.UnrecoverableKeyException: excess private key
at java.base/sun.security.provider.KeyProtector.recover(KeyProtector.java:314)
at java.base/sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:144)
at java.base/sun.security.util.KeyStoreDelegator.engineGetKey(KeyStoreDelegator.java:90)
at java.base/java.security.KeyStore.getKey(KeyStore.java:1057)
at Main.main(Main.java:51)
Я уже пытался регенерировать .jks файл, но получил одинаковую ошибку.
Подробнее здесь: https://stackoverflow.com/questions/758 ... m-jks-file