CRL Problem

hey,

i'm using the following functions: the 1st creates the crl the second revokes certificates

1.

public X509CRL createCRL(String caDN, PrivateKey caPrivKey)throws InvalidKeyException, SecurityException, SignatureException{

X509V2CRLGenerator crlGen =new X509V2CRLGenerator();

crlGen.setIssuerDN(new X509Principal(caDN));

crlGen.setThisUpdate(new Date() );

crlGen.setSignatureAlgorithm("sha1withrsa");

X509CRL crl = crlGen.generateX509CRL(caPrivKey);

return crl;

}

2.

public X509CRL revokeCertificate (X509CRL crl, String caDN, PrivateKey caPrivKey, BigInteger certSerial)throws InvalidKeyException, SecurityException, SignatureException{

// Retrieve the current list of revoked certs

Iterator revokedCerts = crl.getRevokedCertificates().iterator();

// Bouncy Castle class

X509V2CRLGenerator gen =new X509V2CRLGenerator();

gen.setIssuerDN(new X509Principal(caDN));

while(revokedCerts.hasNext() ){

BigInteger revokedSerial = ( (X509Certificate)

revokedCerts.next() ).getSerialNumber();

gen.addCRLEntry(revokedSerial,

crl.getRevokedCertificate(revokedSerial).getRevocationDate(), 0);

}

gen.addCRLEntry(certSerial,new Date(), 0);

// Replace current revocation list with the newly generated

crl = gen.generateX509CRL(caPrivKey);

return crl;

}

the 1. one works fine but in the second function i get a nullpointer exception at the second line

Iterator revokedCerts = crl.getRevokedCertificates().iterator();

when i remove that line and the whole while loop i get a nullpointer exception at the second last line

crl = gen.generateX509CRL(caPrivKey);

does anyone have an idea?

many thanks

toto

[2515 byte] By [Totoa] at [2007-10-2 20:33:00]
# 1
ok i got it working
Totoa at 2007-7-13 23:16:10 > top of Java-index,Security,Cryptography...