PasswordFinder passwordFinder = new PasswordFinder() {
public char[] getPassword() {
return passPhrase != null ? passPhrase.toCharArray() : new char[] {};
}
};
PEMReader pemReader = new PEMReader(new InputStreamReader(pkInputStream), passwordFinder);
KeyPair kp = (KeyPair) pemReader.readObject();
PrivateKey privKey = kp.getPrivate();
// Load certificates found in the PEM input stream
List<X509Certificate> certs = new ArrayList<X509Certificate>();
for (Certificate cert : CertificateFactory.getInstance("X509").generateCertificates(inputStream)) {