I'm able to find the certificate stored against the key alias if I 
use BouncyCastleProvider instead of the default SunJSSE provider. 
 Security.addProvider(new BouncyCastleProvider()); 
 KeyStore keyStore = KeyStore.getInstance("pkcs12","BC");
 
Any idea why it works now?
 
thanks
Kannan

--- On Thu, 9/12/10, Kannan J <kannan_jayapraka...@yahoo.co.in> wrote:


From: Kannan J <kannan_jayapraka...@yahoo.co.in>
Subject: p12 file created using openssl doesn't have the certificate stored 
against the alias.
To: openssl-users@openssl.org
Date: Thursday, 9 December, 2010, 11:49 PM







I have a certificate file MSCACertificate.cer and the corresponding private key 
MSCAPrivateKey.pem from which I created a p12 file MSCACertificateBundle.p12 
using the command
D:\>openssl pkcs12 -export -out MSCACertificateBundle.p12 -inkey MSCAPrivateKey.
pem -in MSCACertificate.cer
When I try to read the Certificate using the below java code, it fails to find 
the certificate against the alias (which happens to be "1"). I'm attaching the 
certificate, key and the p12 bundle. Please advice.
 
 InputStream inStream = new FileInputStream("D:/MSCACertificateBundle.p12");    
   
  KeyStore keyStore = KeyStore.getInstance("pkcs12");
  keyStore.load(inStream,null);
  inStream.close();
  String alias = (String) keyStore.aliases().nextElement();
  if(keyStore.getCertificate(alias) == null)
                Assert.fail("Certificate null");

 
thanks,
Kannan    


Reply via email to