Hi Guy's ,
Im now finally trying your demo, and we are petty happy with it.
The only things is im having problems to get the CRL from the certificate.
We always got an empty collection when calling
Collection<? extends CRL> generatedCRL = cf.generateCRLs();
May you give me an example of how we can get the CRL with your tool please, this is the only thing that miss before buying your api.
here my code :
public static void main(String[] args)
{
try
{
Security.addProvider(new JCAPIProvider());
KeyStore ks = KeyStore.getInstance("msks", "JCAPI");
ks.load(null, null);
String alias = null;
RSAPrivateKey privateKey = null;
// Force JCAPI to export private keys.
JCAPIProperties.getInstance().setPrivateKeyExportable(true);
System.out.println("Trying to find an exportable RSA private key.");
// Get first available RSA private key.
for (java.util.Enumeration e = ks.aliases(); e.hasMoreElements();)
{
alias = (String) e.nextElement();
if (ks.isKeyEntry(alias))
{
privateKey = (RSAPrivateKey) ks.getKey(alias, null);
getCRLFromCertificate(ks.getCertificate(alias));
ks.getCertificateChain(alias);
}
break;
}
}
catch (Throwable t)
{
System.err.println("Example program failed.");
t.printStackTrace();
}
}
private static void getCRLFromCertificate(Certificate c) throws Exception
{
CertificateFactory cf = CertificateFactory.getInstance("X.509");
ByteArrayInputStream bais = new ByteArrayInputStream(c.getEncoded());
cf.generateCertificate(bais);
Collection<? extends CRL> generatedCRL = cf.generateCRLs(bais);
bais.close();
// why this is always 0 ?!?!?!
System.out.println(generatedCRL.size());
}
Thank in advance
Chris