Download keystore file, alias not found

I am trying to use KeyStore to get information from a keystore. I created a keystore using the following command:

keytool -genkey -alias server -keyalg RSA -keystore server.keystore -validity 365This page is removed .

Checking his information keytool -list -v -keystore server.keystoreI get the following:

Alias ​​name: server
Creation date: April 30, 2014
Record type: PrivateKeyEntry
Certificate chain length: 1
Certificate [1]:
(other information here)

With this command: keytool -list -keystore server.keystore -alias serverI get the following:

server, April 30, 2014, PrivateKeyEntry, Certificate fingerprint (SHA1): 28: 65: 5B: 0C: B3: 3C: C9: AA: F1: 7C: CE: 91: 23: 77: DD: 0D: F8: 54: 70: B9

Now, my java code:

keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(getClass().getResourceAsStream(KEYSTORE_FILE_PATH), "myPass".toCharArray());
keyStore.getCertificate("server").getPublicKey().getEncoded(); //here I get a null pointer exception - keystore.getCertificate("server") returns null. 

keyStore.aliases() EmptyEnumeration.

maven, java ee 7, . KEYSTORE_FILE_PATH "/server.keystore".

.

+4
1

Class.getResourceAsStream() null, . KeyStore.load() null.

, .

  • , , getResourceAsStream() , KeyStore.load().
  • / maven, , .

questions getResourceAsStream(), .

+4

Source: https://habr.com/ru/post/1538787/


All Articles