我有一個Base-64編碼的X.509(.CER)證書,它在下面的java代碼中導致NullPointerException。導致它的行是PublicKey pubKey = pubCert.getPublicKey();
從密鑰庫中加載證書
有沒有辦法來驗證myfile.keystore是否有「xyz」證書?
final FileInputStream keyFile = new FileInputStream(filePath
+ "myfile.keystore");
final KeyStore keyStore = KeyStore.getInstance("JKS");
String storepass = "mypass";
keyStore.load(keyFile, storepass.toCharArray());
Certificate pubCert = keyStore.getCertificate("xyz");
PublicKey pubKey = pubCert.getPublicKey();
別名已經改變,這幫助我知道這一點。 – c12