public class X509CRL extends java.security.cert.X509CRL implements ASN1Type
A Certificate Revocation List (CRL) denotes a list of certificates that have been revoked for some reason (e.g. the name of the subject has changed, the private key can no more being treated to be only known by the subject, ...) prior to the regular ending of its validity period. A CRL is maintained by a certification authority (CA) making it publicly available and refreshing it in certain time intervals. Each revoked certificate included in a revocation list can be identified by its serial number. The revocation list is signed by the maintaining CA.
A profile for X.509v2 revocation lists is presented together with the X.509v3 certificate format in RFC 3280, where a CRL is defined as an ASN.1 SEQUENCE structure containing the following components:
CertificateList ::= SEQUENCE { tbsCertList TBSCertList, signatureAlgorithm AlgorithmIdentifier, signatureValue BIT STRING }
where signatureAlgorithm identifies the signature algorithm used by
the signing certification authority for computing the digital signature upon
the ASN.1 DER encoded TBSCertList
structure, which itself is
expressed as ASN.1 SEQUENCE structure specifying the (distinguished) name of
the issuer, the issue date of the CRL, the date when the next CRL will be
issued, and optionally lists of revoked certificates (identified by their
serial numbers) and CRL extensions. The list of revoked certificates is
classified as being optional since a CA may not have revoked any issued
certificate when publishing a CRL.
ASN.1 definition:
TBSCertList ::= SEQUENCE { version Version OPTIONAL, -- if present, must be v2 signature AlgorithmIdentifier, issuer Name, thisUpdate Time, nextUpdate Time OPTIONAL, revokedCertificates SEQUENCE OF SEQUENCE { userCertificate CertificateSerialNumber, revocationDate Time, crlEntryExtensions Extensions OPTIONAL -- if present, must be v2 } OPTIONAL, crlExtensions [0] EXPLICIT Extensions OPTIONAL -- if present, must be v2 }
where:
Version ::= INTEGER { v1(0), v2(1), v3(2) } -- v3 does not apply to CRLs but appears for consistency -- with definition of Version for certs
AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL } -- contains a value of the type -- registered for use with the -- algorithm object identifier value
Name ::= CHOICE { RDNSequence }
RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
RelativeDistinguishedName ::= SET OF AttributeTypeAndValue
AttributeTypeAndValue ::= SEQUENCE { type AttributeType, value AttributeValue }
AttributeType ::= OBJECT IDENTIFIER
AttributeValue ::= ANY -- Directory string type --
DirectoryString ::= CHOICE { teletexString TeletexString (SIZE (1..MAX)), printableString PrintableString (SIZE (1..MAX)), universalString UniversalString (SIZE (1..MAX)), utf8String UTF8String (SIZE (1..MAX)), bmpString BMPString (SIZE (1..MAX)) } }
Time ::= CHOICE { utcTime UTCTime, generalTime GeneralizedTime }
CertificateSerialNumber ::= INTEGER
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING }
For a detail description of the several fields refer to RFC 3280.
For each value exists a setValue()
and a getValue()
method. After creating a X509CRL, the, for instance, CRL issuing date may be
set to the current date by using the setThisUpdate
method:
X509CRL crl = new X509CRL(); GregorianCalendar date = (GregorianCalendar) Calendar.getInstance(); crl.setThisUpdate(date.getTime());
Manipulating the extensions of a CRL is described in class
X509Extensions
. A CRL extension (support
introduced by the X.509v2 CRL format) may be a defined standard
extension (e.g. CRLNumber
, ...), or it may be a private
extension providing some community-specific information. If an extension is
marked as critical, but the CRL handling software cannot parse this
extension, the CRL validation must fail. Non-Critical extensions can
be ignored, if they cannot be handled (i.e. of unknown state).
For adding some extension to a X509CRL use the
addExtension
method. The CRL profile
presented in RFC 3280
requires confirming CAs to support the CRL number extension conveying a
monotonically increasing sequence number for each CRL issued by a given CA
through a specific CA X.500 Directory entry or CRL distribution point, e.g.:
X509CRL crl = new X509CRL(); ... CRLNumber crl_number = new CRLNumber(BigInteger.valueOf(4234234)); crl.addExtension(crl_number);
A X509Certificate
to be revoked may be
added by means of the addCertificate(X509Certificate cert, Date revocationDate)
method.
Alternatively an instance of RevokedCertificate
may be added by using the
addCertificate(RevokedCertificate
revokedCertificate)
method. For finally signing the CRL with the CRL
issuer's private key, call the sign
method.
The X509CRL(byte[])
and
X509CRL(InputStream)
constructors may be used
for parsing an X509CRL from its DER encoding.
This class supports indirect CRLs, i.e. revocation of certificates where certificate issuer is different than the CRL issuer. Some caveats apply though. Firstly, the methods isRevoked(BigInteger) containsCertificate(BigInteger) implicitly assume the CRL issuer as the certificate issuer. Secondly, when encoding an indirect CRL the certificate issuer CRL entry extension is automatically added to entries where needed. However, the issuing distribution point CRL extension also required for indirect CRLs has to be added manually.
Certificate objects used with this class shall be instances of
and Principal objects
shall be instances of iaik.x509.X509Certificate
.
If not, this class tries to internally to iaik.asn1.structures.Name
iaik.x509.X509Certificate
iaik.asn1.structures.Name
Being extended from java.security.cert.X509CRL
this class also
works with general java
X509Extensions
,
V3Extension
,
UnknownExtension
,
X509Certificate
,
RevokedCertificate
,
X509CRL
Constructor and Description |
---|
X509CRL()
Default constructor for creating a new empty X509CRL.
|
X509CRL(ASN1Object asn1CRL)
Creates a X509CRL form a ASN1Object.
|
X509CRL(byte[] crl)
Creates a CRL form a PEM or DER byte array.
|
X509CRL(java.io.InputStream is)
Creates a CRL from an input stream supplying a DER or PEM encoded CRL.
|
Modifier and Type | Method and Description |
---|---|
void |
addCertificate(RevokedCertificate revokedCert)
Adds a revoked certificate to the CRL.
|
void |
addCertificate(X509Certificate cert,
java.util.Date revocationDate)
Adds a certificate to the CRL to be revoked on the given date.
|
void |
addExtension(V3Extension e)
Adds the given X509v2 CRL extension.
|
RevokedCertificate |
containsCertificate(java.math.BigInteger serialNumber)
Checks, if the CRL contains a certificate with the given serial number.
|
RevokedCertificate |
containsCertificate(java.security.Principal issuerDN,
java.math.BigInteger serialNumber)
Checks, if the CRL contains the given certificate, identified by issuer and
serial number.
|
RevokedCertificate |
containsCertificate(X509Certificate cert)
Checks, if the CRL contains the given certificate.
|
int |
countExtensions()
Returns the number of extensions included into this CRL.
|
void |
decode(ASN1Object crl)
Creates a CRL from an ASN1Object.
|
java.util.Set |
getCriticalExtensionOIDs()
Returns a Set of the OID strings identifying the extension(s) that are
marked CRITICAL in this CRL.
|
byte[] |
getEncoded()
Returns this CRL as DER encoded ASN.1 data structure.
|
V3Extension |
getExtension(ObjectID oid)
Returns a specific extension, identified by its object identifier.
|
byte[] |
getExtensionValue(java.lang.String oid)
Returns a byte array representing the DER encoding of the
extnValue OCTET STRING field of the extension identified by
the given OID string. |
byte[] |
getFingerprint()
Returns the fingerprint of this CRL.
|
byte[] |
getFingerprint(java.lang.String digestAlgorithm)
Returns the fingerprint of this crl calculated with the given hash
algorithm.
|
byte[] |
getFingerprintSHA()
Gets the SHA-1 fingerprint of this CRL.
|
java.security.Principal |
getIssuerDN()
Returns the Distinguished Name of the issuer of this CRL, as
Principal . |
java.util.Enumeration |
getIssuerDNs()
Return the names of all issuers of this CRL.
|
java.util.Date |
getNextUpdate()
Returns the date of
nextUpdate . |
java.util.Set |
getNonCriticalExtensionOIDs()
Returns a Set of the OID strings for the extension(s) marked NON-CRITICAL
in this CRL.
|
byte[] |
getRawExtensionValue(java.lang.String oid)
Returns a byte array representing the DER encoding of the extension value
identified by the given OID string.
|
java.security.cert.X509CRLEntry |
getRevokedCertificate(java.math.BigInteger serialNumber)
Searches the CRL for the specified serial number and returns the
appertaining revoked certificate, if included into this CRL.
|
java.security.cert.X509CRLEntry |
getRevokedCertificate(java.security.cert.X509Certificate certificate)
Checks, if the CRL contains the given certificate.
|
java.util.Set |
getRevokedCertificates()
Returns a set containing all the revoked certificates included in this CRL.
|
java.lang.String |
getSigAlgName()
Returns the (JCA standard) name of the signature algorithm used by the issuer for signing
this CRL.
|
java.lang.String |
getSigAlgOID()
Returns the OID of the signature algorithm used by the issuer for signing
this CRL.
|
byte[] |
getSigAlgParams()
Returns the algorithm parameters associated with the signature algorithm
used by the issuer for signing this CRL.
|
byte[] |
getSignature()
Returns the signature of this CRL.
|
AlgorithmID |
getSignatureAlgorithm()
Returns the signature algorithm of this CRL.
|
byte[] |
getTBSCertList()
Returns the
TBSCertList inherent to this CRL as DER encoded
ASN.1 structure. |
java.util.Date |
getThisUpdate()
Returns the date of
thisUpdate . |
int |
getVersion()
Returns the version number of this CRL as
int . |
boolean |
hasExtensions()
Checks, if there are any extensions included into this CRL.
|
boolean |
hasUnsupportedCriticalExtension()
Returns true if there are unsupported critical extensions.
|
boolean |
isIndirectCRL()
Return whether this CRL is an indirect CRL.
|
boolean |
isRevoked(java.math.BigInteger serialNumber)
Checks if the certificate identified by the given serial number is marked
as revoked by this CRL.
|
boolean |
isRevoked(java.security.cert.Certificate cert)
Checks whether the given certificate is on this CRL.
|
java.util.Enumeration |
listCertificates()
Returns an enumeration of the revoked certificates this CRL contains.
|
java.util.Enumeration |
listExtensions()
Returns an enumeration of all extensions included into this CRL.
|
void |
removeAllCertificates()
Removes all certificates from the CRL.
|
void |
removeAllExtensions()
Removes all extensions from this CRL.
|
boolean |
removeCertificate(java.math.BigInteger serialNumber)
Removes the certificate with the given serial number from the CRL.
|
boolean |
removeCertificate(java.security.Principal certIssuer,
java.math.BigInteger serialNumber)
Removes a certificate, identified by its issuer dn and its serial number,
from the crl.
|
boolean |
removeCertificate(X509Certificate cert)
Removes the certificate from the CRL.
|
boolean |
removeExtension(ObjectID oid)
Removes the extension specified by its object identifier.
|
void |
setIssuerDN(java.security.Principal issuer)
Sets the issuer of this CRL.
|
void |
setNextUpdate(java.util.Date nextUpdate)
Sets the date of
nextUpdate . |
void |
setSignature(byte[] signatureValue)
Sets the signature value of this crl.
|
void |
setSignatureAlgorithm(AlgorithmID signatureAlg)
Sets the signature algorithm for signing this CRL.
|
void |
setSignatureAlgorithm(ObjectID signatureAlg)
Deprecated.
use setSignatureAlgorithm(AlgorithmID);
|
void |
setThisUpdate(java.util.Date thisUpdate)
Sets the date of
thisUpdate . |
void |
sign(java.security.PrivateKey privateKey)
Signs the CRL with the private key of the issuer.
|
void |
sign(java.security.PrivateKey privateKey,
java.security.spec.AlgorithmParameterSpec signatureParams,
java.security.Provider provider)
Signs the CRL with the private key of the issuer.
|
void |
sign(java.security.PrivateKey privateKey,
java.security.spec.AlgorithmParameterSpec signatureParams,
java.lang.String providerName)
Signs the CRL with the private key of the issuer.
|
void |
sign(java.security.PrivateKey privateKey,
java.security.Provider provider)
Signs the CRL with the private key of the issuer.
|
void |
sign(java.security.PrivateKey privateKey,
java.lang.String providerName)
Signs the CRL with the private key of the issuer.
|
int |
size()
Gets the size (number of entries) of this crl.
|
ASN1Object |
toASN1Object()
Returns the CRL as an ASN1Object.
|
byte[] |
toByteArray()
Returns the CRL as a DER encoded ASN.1 data structure.
|
java.lang.String |
toString()
Returns a string that represents the contents of the CRL.
|
java.lang.String |
toString(boolean detailed)
Returns a string giving some - if requested - detailed information about
the contents of the CRL.
|
void |
verify(java.security.PublicKey key)
Verifies a signed CRL using the given public key.
|
void |
verify(java.security.PublicKey key,
java.security.Provider provider)
Uses the given public key to verify this CRL based on a signature algorithm
supplied by the given provider.
|
void |
verify(java.security.PublicKey key,
java.lang.String providerName)
Uses the given public key to verify this CRL based on a signature algorithm
supplied by the specified provider.
|
void |
writeTo(java.io.OutputStream os)
Writes the CRL DER encoded to the given output stream.
|
public X509CRL()
Any value may be set using the corresponding the
set<Value>
method. The version number per default is set
to 1
indicating a Version 1
CRL. When
extensions are added
, the version field
automatically is set to 2.
public X509CRL(java.io.InputStream is) throws java.io.IOException, java.security.cert.CRLException
This constructor reads a DER or PEM encoded X509CRL that previously may
have been written with method writeTo(OutputStream)
.
For instance:
InputStream fis = new FileInputStream("crl.der"); X509CRL crl = new X509CRL(fis); fis.close();
is
- InputStream from which to create the CRLjava.io.IOException
- if the CRL could not be readjava.security.cert.CRLException
- if there is a problem when parsing the CRLpublic X509CRL(byte[] crl) throws java.security.cert.CRLException
This constructor may be used for parsing an already existing
X509CRL
ASN.1 object, supplied as DER encoded byte array,
which may have been created by calling the toByteArray
or the getEncoded
method.
crl
- the byte array which contains the CRLjava.security.cert.CRLException
- if there is a problem when parsing the CRLpublic X509CRL(ASN1Object asn1CRL) throws java.security.cert.CRLException
This constructor may be used for parsing an already existing
X509CRL
, supplied as ASN.1 object.
asn1CRL
- the crl as ASN1Objectjava.security.cert.CRLException
- if the format of the CRL is wrongpublic void decode(ASN1Object crl) throws CodingException
The given ASN1Object represents an already existing X509CRL which may have
been created by calling the toASN1Object
method.
decode
in interface ASN1Type
crl
- the ASN1Object which contains the CRLCodingException
- if there is a problem when parsing the CRLpublic boolean isIndirectCRL()
public void sign(java.security.PrivateKey privateKey) throws java.security.cert.CRLException, java.security.InvalidKeyException, java.security.NoSuchAlgorithmException
privateKey
- the private key of the issuerjava.security.cert.CRLException
- if the CRL could not be createdjava.security.InvalidKeyException
- if the private key is not validjava.security.NoSuchAlgorithmException
- if the signature algorithm is not supportedpublic void sign(java.security.PrivateKey privateKey, java.lang.String providerName) throws java.security.cert.CRLException, java.security.InvalidKeyException, java.security.NoSuchAlgorithmException
privateKey
- the private key of the issuerproviderName
- the name of the provider supplying the Signature engine to be used;
if null
the first available provider will be used
the supports the signature algorithmjava.security.cert.CRLException
- if the CRL could not be createdjava.security.InvalidKeyException
- if the private key is not validjava.security.NoSuchAlgorithmException
- if the signature algorithm is not supportedpublic void sign(java.security.PrivateKey privateKey, java.security.spec.AlgorithmParameterSpec signatureParams, java.lang.String providerName) throws java.security.cert.CRLException, java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterException
privateKey
- the private key of the issuersignatureParams
- any signature parameters to -- if not null
-- be
used for initializing the Signature engine; if applicable the parameters
are also set for the signatureAlg
AlgorithmID (if it
does not contain any parameters yetproviderName
- the name of the provider supplying the Signature engine to be used;
if null
the first available provider will be used
the supports the signature algorithmjava.security.cert.CRLException
- if the CRL could not be createdjava.security.InvalidKeyException
- if the private key is not validjava.security.NoSuchAlgorithmException
- if the signature algorithm is not supportedjava.security.InvalidAlgorithmParameterException
- if an error occurs when trying to set the signature parameterspublic void sign(java.security.PrivateKey privateKey, java.security.Provider provider) throws java.security.cert.CRLException, java.security.InvalidKeyException, java.security.NoSuchAlgorithmException
Signature
engine from the given provider
for signing the crl.
Signature.getInstance(algorithm,provider)
is not available method Signature.getInstance(algorithm,provider.getName())
is tried.privateKey
- the private key of the issuerprovider
- the provider supplying the Signature engine to be used;
if null
the first available provider will be used
the supports the signature algorithmjava.security.cert.CRLException
- if the CRL could not be createdjava.security.InvalidKeyException
- if the private key is not validjava.security.NoSuchAlgorithmException
- if the signature algorithm is not supportedpublic void sign(java.security.PrivateKey privateKey, java.security.spec.AlgorithmParameterSpec signatureParams, java.security.Provider provider) throws java.security.cert.CRLException, java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterException
Signature
engine from the given provider
for signing the crl.
Signature.getInstance(algorithm,provider)
is not available method Signature.getInstance(algorithm,provider.getName())
is tried.privateKey
- the private key of the issuersignatureParams
- any signature parameters to -- if not null
-- be
used for initializing the Signature engine; if applicable the parameters
are also set for the signatureAlg
AlgorithmID (if it
does not contain any parameters yet)provider
- the provider supplying the Signature engine to be used;
if null
the first available provider will be used
the supports the signature algorithmjava.security.cert.CRLException
- if the CRL could not be createdjava.security.InvalidKeyException
- if the private key is not validjava.security.NoSuchAlgorithmException
- if the signature algorithm is not supportedjava.security.InvalidAlgorithmParameterException
- if an error occurs when trying to set the signature parameterspublic void setSignature(byte[] signatureValue) throws java.security.cert.CRLException
This method provides an alternative to method sign
when it is
required to set the signature value from outside (e.g. calculated by means
of a smartcard):
X509CRL crl = ...; ... // set issuer, revoked certificates, ... ... // set the signature algorithm to be used for signing crl.setSignatureAlgorithm(AlgorithmID.sha1WithRSAEncryption); // get the to-be-signed value byte[] tbs = crl.getTBSCertList(); // now calculate the signature over the tbs cert list byte[] signatureValue = calculateSignature(tbs); // and set the signatureValue crl.setSignature(signatureValue); // encode the crl byte[] encodedCrl = crl.getEncoded();
signatureValue
- the signature calculated outsidejava.security.cert.CRLException
- if the CRL could not be createdpublic void verify(java.security.PublicKey key, java.lang.String providerName) throws java.security.cert.CRLException, java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.NoSuchProviderException, java.security.SignatureException
verify
in class java.security.cert.X509CRL
key
- the public key of the CRL issuerproviderName
- the name of the provider supplying the Signature engine to be used;
if null
the first available provider will be used
the supports the signature algorithmjava.security.cert.CRLException
- if an encoding error occursjava.security.NoSuchAlgorithmException
- if there is no implementation for the algorithm used to sign
this CRLjava.security.InvalidKeyException
- if the format of the public key is wrongjava.security.NoSuchProviderException
- if there is no default providerjava.security.SignatureException
- if the signature does not verifypublic void verify(java.security.PublicKey key, java.security.Provider provider) throws java.security.cert.CRLException, java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.SignatureException
This method uses a Signature
engine from the given provider
for verifying the crl.
If Provider object based JCA/JCE Signature engine instantiation
is not available the Java VM in use (<1.4), this method tries to get an implementation
based on the provider name (if the Provider is installed within the Security Provider
framework). I.e. if method Signature.getInstance(algorithm,provider)
is not available method Signature.getInstance(algorithm,provider.getName())
is tried.
key
- the public key of the CRL issuerprovider
- the provider supplying the Signature engine to be used;
if null
the first available provider will be used
the supports the signature algorithmjava.security.cert.CRLException
- if an encoding error occursjava.security.NoSuchAlgorithmException
- if there is no implementation for the algorithm used to sign
this CRLjava.security.InvalidKeyException
- if the format of the public key is wrongjava.security.SignatureException
- if the signature does not verifypublic void verify(java.security.PublicKey key) throws java.security.cert.CRLException, java.security.NoSuchAlgorithmException, java.security.InvalidKeyException, java.security.NoSuchProviderException, java.security.SignatureException
verify(PublicKey key, String
sigProvider)
setting the provider name to null
for relying on
the default provider signature architecture.verify
in class java.security.cert.X509CRL
key
- the public key of the CRL issuerjava.security.cert.CRLException
- if an encoding error occursjava.security.NoSuchAlgorithmException
- if there is no implementation for the algorithm used to sign
this CRLjava.security.InvalidKeyException
- if the format of the public key is wrongjava.security.NoSuchProviderException
- if there is no default providerjava.security.SignatureException
- if the signature does not verifypublic boolean isRevoked(java.math.BigInteger serialNumber)
Note that the information returned by this method may be only appropriate
for direct CRL entries (where the crl issuer is equal to the certificate
issuer). Generally you should prefer method
because it is also able to properly handle indirect
crl entries.isRevoked
serialNumber
- the serial number of the certificate which is checked of being
revokedtrue
if the certificate identified by the given serial
number is marked as revoked by this CRL, false
if notpublic boolean isRevoked(java.security.cert.Certificate cert)
isRevoked
in class java.security.cert.CRL
cert
- the certificate to check for, shall be an iaik.x509.X509Certificate
(if not, the given cert is tried to converted to an iaik.x509.X509Certificate
)java.lang.IllegalArgumentException
- if the certificate is not an iaik.x509.X509Certificate
and cannot be converted to an iaik.x509.X509Certificatepublic RevokedCertificate containsCertificate(X509Certificate cert)
The RevokedCertificate
object returned by this method may
represent an indirect CRL entry (certificate issuer != crl issuer) which
may (but must not) contain a CertificateIssuer
extension. It will contain a CertificateIssuer extension if it is the first
entry in the sequence of entries for the this certificate issuer. It may or
may not contain a CertificateIssuer extension if it is not the first entry
in the sequence of entries for this certificate issuer. However, the
certificate issuerDN is already known when calling this method, thus it is
not necessary to include a CertificateIssuer extension into the
RevokedCertificate.
Remember the order of entries in an indirect crl: it may start with direct
entries which refer to certificates that have been directly issued by the
crl issuer. These entries must not contain a CertificateIssuer extension.
Each sequence of entries that refer to certificates which have NOT been
issued by the crl issuer must start with a RevokedCertificate entry that
must contain a CertificateIssuer extension with the name of the certificate
issuer. The following entries must not contain a CertificateIssuer
extension as long as they have been issued by the same issuer, e.g.:
1. direct entry 2. direct entry ... 10. direct entry 11. indirect entry (with CertificateIssuer extension for CertIssuer 1) 12. indirect entry 13. indirect entry ... 18. indirect entry 19. indirect entry (with CertificateIssuer extension for CertIssuer 2) 20. indirect entry 21. indirect entry ... 24. indirect entry 25. indirect entry (with CertificateIssuer extension for CertIssuer 3) 26. indirect entry 27. indirect entry ... 34. indirect entryEntry 1 to 10 of this example crl are direct entries that refer to certificates that have been issued by the crl issuer. Entry 11 to 18 are indirect entries, all referring to certificates that have been issued by CertIssuer1. Entry 19 to 24 refer to certificates that have been issued by CertIssuer2, entry 25 to 34 refer to certificates that have been issued by CertIssuer3. Only the first entry (11., 19., 25.) for each cert issuer must contain the CertificateIssuer extension, any following entry belongs to the same certificate issuer as the preceding entry.
cert
- the certificate to checkpublic RevokedCertificate containsCertificate(java.security.Principal issuerDN, java.math.BigInteger serialNumber)
The RevokedCertificate
object returned by this method may
represent an indirect CRL entry (certificate issuer != crl issuer) which
may (but must not) contain a CertificateIssuer
extension. It will contain a CertificateIssuer extension if it is the first
entry in the sequence of entries for the this certificate issuer. It may or
may not contain a CertificateIssuer extension if it is not the first entry
in the sequence of entries for this certificate issuer. However, the
certificate issuerDN is already known when calling this method, thus it is
not necessary to include a CertificateIssuer extension into the
RevokedCertificate.
Remember the order of entries in an indirect crl: it may start with direct
entries which refer to certificates that have been directly issued by the
crl issuer. These entries must not contain a CertificateIssuer extension.
Each sequence of entries that refer to certificates which have NOT been
issued by the crl issuer must start with a RevokedCertificate entry that
must contain a CertificateIssuer extension with the name of the certificate
issuer. The following entries must not contain a CertificateIssuer
extension as long as they have been issued by the same issuer, e.g.:
1. direct entry 2. direct entry ... 10. direct entry 11. indirect entry (with CertificateIssuer extension for CertIssuer 1) 12. indirect entry 13. indirect entry ... 18. indirect entry 19. indirect entry (with CertificateIssuer extension for CertIssuer 2) 20. indirect entry 21. indirect entry ... 24. indirect entry 25. indirect entry (with CertificateIssuer extension for CertIssuer 3) 26. indirect entry 27. indirect entry ... 34. indirect entryEntry 1 to 10 of this example crl are direct entries that refer to certificates that have been issued by the crl issuer. Entry 11 to 18 are indirect entries, all referring to certificates that have been issued by CertIssuer1. Entry 19 to 24 refer to certificates that have been issued by CertIssuer2, entry 25 to 34 refer to certificates that have been issued by CertIssuer3. Only the first entry (11., 19., 25.) for each cert issuer must contain the CertificateIssuer extension, any following entry belongs to the same certificate issuer as the preceding entry.
issuerDN
- the certificate issuer; shall be an iaik.asn1.structures.Name
;
if not, the issuerDN is tried to converted to an iaik.asn1.structures.Name
objectserialNumber
- the certificate serial numberjava.lang.IllegalArgumentException
- if the issuerDN cannot be converted to an
iaik.asn1.structures.Name
objectpublic RevokedCertificate containsCertificate(java.math.BigInteger serialNumber)
Note that the information returned by this method may be only appropriate
for direct CRL entries (where the crl issuer is equal to the certificate
issuer). Generally you should prefer method
because it is also able to properly
handle indirect crl entries.containsCertificate
serialNumber
- the serial number of the certificatenull
if the CRL doesn't contain a certificate with
this serial number, the RevokedCertificate from the CRL otherwisepublic ASN1Object toASN1Object()
toASN1Object
in interface ASN1Type
public byte[] toByteArray()
public void writeTo(java.io.OutputStream os) throws java.io.IOException
os
- the output stream to which this CRL shall be writtenjava.io.IOException
- if an I/O error occurspublic void addCertificate(X509Certificate cert, java.util.Date revocationDate)
GregorianCalendar date = (GregorianCalendar) Calendar.getInstance(); InputStream fis = new FileInputStream("cert.der"); X509Certificate cert = new X509Certificate(fis); fis.close(); crl.addCertificate(cert, date.getTime());
cert
- the X509Certificate which should be revokedrevocationDate
- the revocation datepublic void addCertificate(RevokedCertificate revokedCert)
addCertificate(X509Certificate cert, Date
revocationDate)
which adds a X509Certificate, this method adds a
RevokedCertificate already including its revocation date, for instance:
GregorianCalendar date = (GregorianCalendar) Calendar.getInstance(); InputStream fis = new FileInputStream("cert.der"); X509Certificate cert = new X509Certificate(fis); fis.close(); RevokedCertificate rev_cert = new RevokedCertificate(cert, date.getTime()); crl.addCertificate(rev_cert);
revokedCert
- the RevokedCertificate to add to this CRLRevokedCertificate
public java.util.Enumeration listCertificates()
The RevokedCertificate
objects returned by this method may
represent direct (certificate issuer == crk issuer) or indirect CRL entries
(certificate issuer != crl issuer). Indirect entries may (but must not)
contain a CertificateIssuer
extension. A
RevokedCertificate that represents an indirect entry will contain a
CertificateIssuer extension if it is the first entry in the sequence of
entries for the this certificate issuer. It may or may not contain a
CertificateIssuer extension if it is not the first entry in the sequence of
entries for this certificate issuer.
In this way the enumeration returned by this method reflects the order of
entries in an (direct or indirect) crl: it may start with direct entries
which refer to certificates that have been directly issued by the crl
issuer. These entries must not contain a CertificateIssuer extension. Each
sequence of entries that refer to certificates which have NOT been issued
by the crl issuer must start with a RevokedCertificate entry that must
contain a CertificateIssuer extension with the name of the certificate
issuer. The following entries must not contain a CertificateIssuer
extension as long as they have been issued by the same issuer, e.g.:
1. direct entry 2. direct entry ... 10. direct entry 11. indirect entry (with CertificateIssuer extension for CertIssuer 1) 12. indirect entry 13. indirect entry ... 18. indirect entry 19. indirect entry (with CertificateIssuer extension for CertIssuer 2) 20. indirect entry 21. indirect entry ... 24. indirect entry 25. indirect entry (with CertificateIssuer extension for CertIssuer 3) 26. indirect entry 27. indirect entry ... 34. indirect entryEntry 1 to 10 of this example crl are direct entries that refer to certificates that have been issued by the crl issuer. Entry 11 to 18 are indirect entries, all referring to certificates that have been issued by CertIssuer1. Entry 19 to 24 refer to certificates that have been issued by CertIssuer2, entry 25 to 34 refer to certificates that have been issued by CertIssuer3. Only the first entry (11., 19., 25.) for each cert issuer must contain the CertificateIssuer extension, any following entry belongs to the same certificate issuer as the preceding entry.
public boolean removeCertificate(X509Certificate cert)
true
if the certificate successfully has been removed
false
otherwisepublic boolean removeCertificate(java.math.BigInteger serialNumber)
crl.removeCertificate(cert.getSerialNumber());
serialNumber
- the serial number of the certificate which should be removedtrue
if the certificate successfully has been removed
false
otherwisepublic boolean removeCertificate(java.security.Principal certIssuer, java.math.BigInteger serialNumber)
certIssuer
- the issuer dn of the certificate; shall be an iaik.asn1.structures.Name
;
if not, the certIssuer is tried to converted to an iaik.asn1.structures.Name
objectserialNumber
- the certificate serial numbertrue
if the certificate successfully has been removed
false
otherwisejava.lang.IllegalArgumentException
- if the certIssuer cannot be converted to an
iaik.asn1.structures.Name
objectpublic void removeAllCertificates()
public int size()
public void setSignatureAlgorithm(AlgorithmID signatureAlg)
crl.setSignatureAlgorithm(AlgorithmID.sha1WithRSAEncryption);
signatureAlg
- the AlgorithmID of the signature algorithm to be used for signingAlgorithmID
public void setSignatureAlgorithm(ObjectID signatureAlg)
public void setIssuerDN(java.security.Principal issuer) throws java.lang.IllegalArgumentException
Name issuer = new Name(); issuer.addRDN(ObjectID.country, "AT"); issuer.addRDN(ObjectID.organization, "TU Graz"); issuer.addRDN(ObjectID.organizationalUnit, "IAIK"); issuer.addRDN(ObjectID.commonName, "IAIK Test CA"); crl.setIssuerDN(issuer);
issuer
- the distinguished name of the issuer of the CRL; shall be an iaik.asn1.structures.Name
;
if not, the issuer is tried to converted to an iaik.asn1.structures.Name
objectjava.lang.IllegalArgumentException
- if the issuer is not an instance of Name and cannot be
converted to a NamegetIssuerDN()
public void setThisUpdate(java.util.Date thisUpdate)
thisUpdate
. The thisUpdate
time
value specifies the date on which the CRL has been issued.
For instance, set ThisUpdate
to the current date by writing:
GregorianCalendar date = (GregorianCalendar) Calendar.getInstance(); crl.setThisUpdate(date.getTime());
The X.509 Certificate and CRL Profile specified in RFC 3280 recommends to encode
thisUpdate
dates through the year 2049 as UTCTime, and
thisUpdate
dates in 2050 or later as GeneralizedTime.
thisUpdate
- the date when this CRL has been issuedgetThisUpdate()
public void setNextUpdate(java.util.Date nextUpdate)
nextUpdate
. The nextUpdate
time
value specifies the date on which the next CRL will be issued.
If the next update will be done, for instance, next month, you may write:
GregorianCalendar date = (GregorianCalendar) Calendar.getInstance(); date.add(Calendar.MONTH, 1); crl.setNextUpdate(date.getTime());
The X.509 Certificate and CRL Profile specified in RFC 3280 recommends to encode
nextUpdate
dates through the year 2049 as UTCTime, and
nextUpdate
dates in 2050 or later as GeneralizedTime.
nextUpdate
- when the next CRL will be createdgetNextUpdate()
public byte[] getEncoded() throws java.security.cert.CRLException
getEncoded
in class java.security.cert.X509CRL
java.security.cert.CRLException
- if an encoding error occurspublic int getVersion()
int
. The version
number may specify a v1 or v2 CRL.
ASN.1 definition:
Version ::= INTEGER { v1(0), v2(1), v3(2) } v3 only appears for consistency reasons
getVersion
in class java.security.cert.X509CRL
int
public AlgorithmID getSignatureAlgorithm()
AlgorithmID
public java.security.Principal getIssuerDN()
Principal
. A Distinguished Name is used to specify a
path within a X.500 directory information tree. A distinguished name is
defined as a sequence of relative distinguished names:
Name ::= CHOICE { RDNSequence } RDNSequence ::= SEQUENCE OF RelativeDistinguishedName RelativeDistinguishedName ::= SET OF AttributeTypeAndValue AttributeTypeAndValue ::= SEQUENCE { type AttributeType, value AttributeValue } AttributeType ::= OBJECT IDENTIFIER AttributeValue ::= ANY
CAs conforming to RFC
3280 have to ensure to only issue crls having a non-empty distinguished
name (DN) in their issuer field. Additional identities about the issuer may
be included in the IssuerAltName
extension.
getIssuerDN
in class java.security.cert.X509CRL
Principal
(iaik.asn1.structures.Name
)setIssuerDN(java.security.Principal)
public java.util.Enumeration getIssuerDNs()
public java.util.Date getThisUpdate()
thisUpdate
. The thisUpdate
time value specifies the date on which the CRL has been issued.
ASN.1 definition:
thisUpdate Time Time ::= CHOICE { utcTime UTCTime, generalTime GeneralizedTime }
The X.509 Certificate and CRL Profile specified in RFC 3280 recommends to encode
thisUpdate
dates through the year 2049 as UTCTime, and
thisUpdate
dates in 2050 or later as GeneralizedTime.
getThisUpdate
in class java.security.cert.X509CRL
setThisUpdate(java.util.Date)
public java.util.Date getNextUpdate()
nextUpdate
. The nextUpdate
time value specifies the date on which the next CRL will be issued.
ASN.1 definition:
nextUpdate Time OPTIONAL Time ::= CHOICE { utcTime UTCTime, generalTime GeneralizedTime }
The PKIX CRL (RFC 3280)
profile requires the inclusion of the nextUpdate
field in CRLs
issued by conforming CAs, although it is marked as OPTIONAL in the ASN.1
definition above.
The X.509 Certificate and CRL Profile specified in RFC 3280 recommends to encode
nextUpdate
dates through the year 2049 as UTCTime, and
nextUpdate
dates in 2050 or later as GeneralizedTime.
getNextUpdate
in class java.security.cert.X509CRL
setNextUpdate(java.util.Date)
public java.security.cert.X509CRLEntry getRevokedCertificate(java.math.BigInteger serialNumber)
Note that the information returned by this method may be only appropriate
for direct CRL entries (where the crl issuer is equal to the certificate
issuer). Generally you should prefer method
because it is also able to properly
handle indirect crl entries.containsCertificate
getRevokedCertificate
in class java.security.cert.X509CRL
serialNumber
- the serial number to be searched fornull
otherwisepublic java.security.cert.X509CRLEntry getRevokedCertificate(java.security.cert.X509Certificate certificate)
The RevokedCertificate
object returned by this method may
represent an indirect CRL entry (certificate issuer != crl issuer) which
may (but must not) contain a CertificateIssuer
extension. It will contain a CertificateIssuer extension if it is the first
entry in the sequence of entries for the this certificate issuer. It may or
may not contain a CertificateIssuer extension if it is not the first entry
in the sequence of entries for this certificate issuer. However, the
certificate issuerDN is already known when calling this method, thus it is
not necessary to include a CertificateIssuer extension into the
RevokedCertificate.
Remember the order of entries in an indirect crl: it may start with direct
entries which refer to certificates that have been directly issued by the
crl issuer. These entries must not contain a CertificateIssuer extension.
Each sequence of entries that refer to certificates which have NOT been
issued by the crl issuer must start with a RevokedCertificate entry that
must contain a CertificateIssuer extension with the name of the certificate
issuer. The following entries must not contain a CertificateIssuer
extension as long as they have been issued by the same issuer, e.g.:
1. direct entry 2. direct entry ... 10. direct entry 11. indirect entry (with CertificateIssuer extension for CertIssuer 1) 12. indirect entry 13. indirect entry ... 18. indirect entry 19. indirect entry (with CertificateIssuer extension for CertIssuer 2) 20. indirect entry 21. indirect entry ... 24. indirect entry 25. indirect entry (with CertificateIssuer extension for CertIssuer 3) 26. indirect entry 27. indirect entry ... 34. indirect entryEntry 1 to 10 of this example crl are direct entries that refer to certificates that have been issued by the crl issuer. Entry 11 to 18 are indirect entries, all referring to certificates that have been issued by CertIssuer1. Entry 19 to 24 refer to certificates that have been issued by CertIssuer2, entry 25 to 34 refer to certificates that have been issued by CertIssuer3. Only the first entry (11., 19., 25.) for each cert issuer must contain the CertificateIssuer extension, any following entry belongs to the same certificate issuer as the preceding entry.
getRevokedCertificate
in class java.security.cert.X509CRL
cert
- the certificate to check; shall be an iaik.x509.X509Certificate
;
if not, the certificate is tried to converted to an iaik.x509.X509Certificate
objectjava.lang.IllegalArgumentException
- if the certificate cannot be converted to an
iaik.x509.X509Certificate
objectpublic java.util.Set getRevokedCertificates()
Unlike method
which returns an Enumeration of revocation entries, this method returns a
Set and therefore may not reflect the order of revoked certificates. For
that reason each listCertificates
RevokedCertificate
object that
represents an indirect crl entry must contain a CertificateIssuer
extension with the name of the responsible certificate
issuer. Thus calling this method is more expensive than calling method
.listCertificates
getRevokedCertificates
in class java.security.cert.X509CRL
null
if there are no
certificates revoked by this CRLpublic byte[] getTBSCertList() throws java.security.cert.CRLException
TBSCertList
inherent to this CRL as DER encoded
ASN.1 structure. The TBSCertList
specifies the (distinguished)
name of the issuer, the issue date of the CRL, the date when the next CRL
will be issued, and optionally lists of revoked certificates (identified by
their serial numbers) and CRL extensions. The list of revoked certificates
is classified as being optional, since a CA may not have revoked any issued
certificate when publishing a CRL:
TBSCertList ::= SEQUENCE { version Version OPTIONAL, -- if present, must be v2 signature AlgorithmIdentifier, issuer Name, thisUpdate Time, nextUpdate Time OPTIONAL, revokedCertificates SEQUENCE OF SEQUENCE { userCertificate CertificateSerialNumber, revocationDate Time, crlEntryExtensions Extensions OPTIONAL -- if present, must be v2 } OPTIONAL, crlExtensions [0] EXPLICIT Extensions OPTIONAL -- if present, must be v2 }
where:
Version ::= INTEGER { v1(0), v2(1), v3(2) } -- v3 does not apply to CRLs but appears for consistency -- with definition of Version for certs
AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL } -- contains a value of the type -- registered for use with the -- algorithm object identifier value
Name ::= CHOICE { RDNSequence }
RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
RelativeDistinguishedName ::= SET OF AttributeTypeAndValue
AttributeTypeAndValue ::= SEQUENCE { type AttributeType, value AttributeValue }
AttributeType ::= OBJECT IDENTIFIER
AttributeValue ::= ANY -- Directory string type --
DirectoryString ::= CHOICE { teletexString TeletexString (SIZE (1..maxSize), printableString PrintableString (SIZE (1..maxSize)), universalString UniversalString (SIZE (1..maxSize)), bmpString BMPString (SIZE(1..maxSIZE)) }
Time ::= CHOICE { utcTime UTCTime, generalTime GeneralizedTime }
CertificateSerialNumber ::= INTEGER
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING }
The CRL issuing CA computes the digital signature upon the ASN.1 DER
encoded TBSCertList
structure.
getTBSCertList
in class java.security.cert.X509CRL
TBSCertList
structure inherent to this CRLjava.security.cert.CRLException
- if an error occurs when parsing the CRLpublic byte[] getSignature()
getSignature
in class java.security.cert.X509CRL
public java.lang.String getSigAlgName()
For the RSA-PSS signature algorithm the JCA standard name is derived from the
algorithm id parameters. Since there is only one AlgorithmID
specified for RSA-PSS, hash algorithm and mask generation function are given by
the algorithm id parameters.
The JCA uses the <digest>with<RSA>and<mgf> naming scheme for RSA-PSS
where <digest> and <mgf> have to be got from the algorithm id parameters.
Thus the JCA standard name for, e.g., a RSA-PSS algorithm id
using SHA-256 as hash algorithm and MGF1 as mask generation function is
"SHA256withRSAandMGF1". If the parameters cannot be parsed, "RSASSA-PSS" is
returned as (general) signature algorithm name.
getSigAlgName
in class java.security.cert.X509CRL
public java.lang.String getSigAlgOID()
getSigAlgOID
in class java.security.cert.X509CRL
ObjectID
,
AlgorithmID
public byte[] getSigAlgParams()
getSigAlgParams
in class java.security.cert.X509CRL
null
if there are no parameters usedpublic java.util.Set getCriticalExtensionOIDs()
getCriticalExtensionOIDs
in interface java.security.cert.X509Extension
null
getNonCriticalExtensionOIDs()
public java.util.Set getNonCriticalExtensionOIDs()
getNonCriticalExtensionOIDs
in interface java.security.cert.X509Extension
getCriticalExtensionOIDs()
public byte[] getExtensionValue(java.lang.String oid)
extnValue
OCTET STRING field of the extension identified by
the given OID string.
The OID string is represented by a set of non-negative integers separated
by periods, e.g. "2.5.29.15" for the KeyUsage
extension.
In ASN.1, the Extensions
field is defined as a SEQUENCE of
Extension:
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING }
where critical
specifies whether an extension has to be
treated as being critical or not; the default value is FALSE. An extension
is identified by its object identifier, specified in the
extnID
field. The extnValue
field is an OCTET
STRING which contains the DER encoding of the specific extension's ASN.1
representation itself. Only one instance of a particular extension may be
present.
The byte value returned by this method represents the DER encoding of the
extnValue (OCTET_STRING) from above, and the value of this OCTET STRING
represents the DER encoding of the specific extension's ASN.1
representation itself. If you want to get the DER encoding of the specific
extension's ASN.1 representation itself (not wrapped in an OCTET STRING),
use method getRawExtensionValue
.
getExtensionValue
in interface java.security.cert.X509Extension
oid
- the object identifier of the extension to be searched fornull
if no
extension with the specified oid is presentpublic byte[] getRawExtensionValue(java.lang.String oid)
The OID string is represented by a set of non-negative integers separated
by periods, e.g. "2.5.29.15" for the KeyUsage
extension.
In ASN.1, the Extensions
field is defined as a SEQUENCE of
Extension:
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING }
where critical
specifies whether an extension has to be
treated as being critical or not; the default value is FALSE. An extension
is identified by its object identifier, specified in the
extnID
field. The extnValue
field is an OCTET
STRING which contains the DER encoding of the specific extension's ASN.1
representation itself. Only one instance of a particular extension may be
present in a particular certificate.
The byte value returned by this method represents the DER encoding of the
specific extension's ASN.1 representation itself (i.e. the value of the
extnValue
OCTET STRING).
oid
- the object identifier of the extension to be searched fornull
if no extension with the specified oid is presentpublic void addExtension(V3Extension e) throws X509ExtensionException
The extension to be added shall be an implemented
V3Extension
. If an extension with the same
object ID already exists, it is replaced.
For instance:
X509CRL crl = new X509CRL(); ... CRLNumber crl_number = new CRLNumber(BigInteger.valueOf(4234234)); crl.addExtension(crl_number);
For getting some extension, use the getExtension(ObjectID)
method.
e
- the X509v2 CRL extension to add to the list of extensionsX509ExtensionException
- if an error occurs while DER encoding the extensionV3Extension
public boolean removeExtension(ObjectID oid)
oid
- the object ID of the extension to removetrue
if the extension successfully has been removed
false
otherwisepublic void removeAllExtensions()
public java.util.Enumeration listExtensions()
The returned enumeration may contain unknown extensions (instances
of UnknownExtension
if there are any
extensions included in this certificate, for which there exists no
registered implementation, and it may contain error extensions
(instances of ErrorExtension
)
indicating extensions which cannot be parsed properly because of some kind
of error.
null
if there are
no extensions present at allpublic boolean hasExtensions()
true
if there are extensions, false
if
notpublic boolean hasUnsupportedCriticalExtension()
hasUnsupportedCriticalExtension
in interface java.security.cert.X509Extension
public int countExtensions()
public V3Extension getExtension(ObjectID oid) throws X509ExtensionInitException
If the extension cannot be initialized for some reason, a
X509ExtensionInitException is thrown. If the requested extension is an
unknown extension, which is not supported by a registered
implementation, this method creates and returns an
UnknownExtension
which may be queried
for obtaining as much information as possible about the unknown extension.
oid
- the object ID of the extensionnull
if the requested
extension is not presentX509ExtensionInitException
- if the extension can not be initializedX509Extensions.getExtension(iaik.asn1.ObjectID)
public byte[] getFingerprint()
public byte[] getFingerprint(java.lang.String digestAlgorithm) throws java.security.NoSuchAlgorithmException
digestAlgorithm
- the digest algorithm to be usedjava.security.NoSuchAlgorithmException
- if the requested algorithm is not supportedpublic byte[] getFingerprintSHA()
public java.lang.String toString()
toString
in class java.security.cert.CRL
public java.lang.String toString(boolean detailed)
detailed
- whether or not to give detailed information about the CRL.