| Brian McIlwrath 2005-11-11, 7:02 pm |
| I have a pkcs12 format certificate file which contains just one key and an
associated 2 certificate chain.
"keytool" says:
Keystore type: pkcs12
Keystore provider: SunJSSE
Your keystore contains 1 entry
Alias name: brian
Creation date: 10-Aug-2005
Entry type: keyEntry
Certificate chain length: 2
etc.
Trying to replicate this in Java I get an null value for "certChain" below
keyStore = KeyStore.getInstance("PKCS12");
System.out.println("Keystore size " + keyStore.size());
// Returns 1
Key key=keyStore.getKey("brian","password".toCharArray());
System.out.println("Key information " + key.getAlgorithm() + " "
+ key.getFormat());
// Key information RSA PKCS#8
Certificate[] certChain = keyStore.getCertificateChain("brian");
System.out.println(certChain.length);
// NullPointerException
What am I doing wrong?
|