All Packages Class Hierarchy This Package Previous Next Index
The extensions defined for X.509 v3 Certificates and v2 CRLs (Certificate Revocation Lists) provide methods for associating additional attributes with users or public keys, for managing the certification hierarchy, and for managing CRL distribution. The X.509 extensions format also allows communities to define private extensions to carry information unique to those communities.
Each extension in a certificate/CRL may be designated as critical or non-critical. A certificate/CRL-using system (an application validating a certificate/CRL) must reject the certificate/CRL if it encounters a critical extension it does not recognize. A non-critical extension may be ignored if it is not recognized.
The ASN.1 definition for this is:
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension Extension ::= SEQUENCE { extnId OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING -- contains a DER encoding of a value -- of the type registered for use with -- the extnId object identifier value }Since not all extensions are known, the
getExtensionValue
method returns the DER-encoded OCTET STRING of the
extension value (i.e., the extnValue
). This can then
be handled by a Class that understands the extension.
oid
String.
public abstract Set getCriticalExtensionOIDs()
InputStream inStrm = new FileInputStream("DER-encoded-Cert");
X509Certificate cert = X509Certificate.getInstance(inStrm);
inStrm.close();
Set critSet = cert.getCriticalExtensionOIDs();
System.out.println("Set of critical extensions");
for (Iterator i = critSet.iterator(); i.hasNext();) {
String oid = (String)i.next();
System.out.println(oid);
}
public abstract Set getNonCriticalExtensionOIDs()
InputStream inStrm = new FileInputStream("DER-encoded-CRL");
X509CRL crl = X509CRL.getInstance(inStrm);
inStrm.close();
byte[] certData = <DER-encoded certificate data>
X509Certificate cert = X509Certificate.getInstance(certData);
RevokedCertificate badCert =
crl.getRevokedCertificate(cert.getSerialNumber());
if (badCert != null) {
Set nonCritSet = badCert.getNonCriticalExtensionOIDs();
for (Iterator i = nonCritSet.iterator(); i.hasNext();) {
String oid = (String)i.next();
System.out.println(oid);
}
}
public abstract byte[] getExtensionValue(String oid)
oid
String.
The oid
string is
represented by a set of positive whole numbers separated
by periods.
For example:
OID | Extension Name |
---|---|
2.5.29.14 | SubjectKeyIdentifier |
2.5.29.15 | KeyUsage |
2.5.29.16 | PrivateKeyUsage |
2.5.29.17 | SubjectAlternativeName |
2.5.29.18 | IssuerAlternativeName |
2.5.29.19 | BasicConstraints |
2.5.29.30 | NameConstraints |
2.5.29.33 | PolicyMappings |
2.5.29.36 | PolicyConstraints |
2.5.29.35 | AuthorityKeyIdentifier |
All Packages Class Hierarchy This Package Previous Next Index