我有一个 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();