For Programmers: Free Programming Magazines  


Home > Archive > Java Security > November 2005 > keystore puzzlement!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author keystore puzzlement!
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?

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com