Interface X509Certificate
- All Superinterfaces:
Certificate
The
X509Certificate interface is the interface to represent X509
certificates as specified in RFC 5280.
In June of 1996, the basic X.509 v3 format was completed by ISO/IEC and ANSI X9, which is described below in ASN.1:
Certificate ::= SEQUENCE {
tbsCertificate TBSCertificate,
signatureAlgorithm AlgorithmIdentifier,
signature BIT STRING }
The ASN.1 definition of tbsCertificate is:
TBSCertificate ::= SEQUENCE {
version [0] EXPLICIT Version DEFAULT v1,
serialNumber CertificateSerialNumber,
signature AlgorithmIdentifier,
issuer Name,
validity Validity,
subject Name,
subjectPublicKeyInfo SubjectPublicKeyInfo,
issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL,
-- If present, version must be v2 or v3
subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL,
-- If present, version must be v2 or v3
extensions [3] EXPLICIT Extensions OPTIONAL
-- If present, version must be v3
}
Version ::= INTEGER { v1(0), v2(1), v3(2) }
CertificateSerialNumber ::= INTEGER
Validity ::= SEQUENCE {
notBefore Time,
notAfter Time }
Time ::= CHOICE {
utcTime UTCTime,
generalTime GeneralizedTime }
UniqueIdentifier ::= BIT STRING
SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING }
Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
Extension ::= SEQUENCE {
extnID OBJECT IDENTIFIER,
critical BOOLEAN DEFAULT FALSE,
extnValue OCTET STRING
-- contains the DER encoding of an ASN.1 value
-- corresponding to the extension type identified
-- by extnID
}
- Since:
- 3.1
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceExtensionHandleris a specializedCertificateParser.ParserHandlerthat will be triggered by theCertificateParsereach time a certificate extension is found.static interfaceFieldHandleris a specializedCertificateParser.ParserHandlerthat will be triggered by theCertificateParsereach time a certificate field is found. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final shortField identifier for the DER-encoding of the certificate signature (signature BIT STRING of Certificate asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the certificate signature algorithm (signatureAlgorithm SEQUENCE of Certificate asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the certificate To Be Signed (TBSCertificate SEQUENCE of Certificate asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the the To Be Signed certificate issuer (issuer CHOICE of TBSCertificate asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the the To Be Signed certificate issuer unique identifier (issuerUniqueID BIT STRING of TBSCertificate asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the notAfter validity time (notAfter CHOICE of the Validity asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the notBefore validity time (notBefore CHOICE of the Validity asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the the To Be Signed certificate public key info (subjectPublicKeyInfo SEQUENCE of TBSCertificate asn.1 SEQUENCE).static final shortField identifier for the INTEGER DER-encoding of the To Be Signed certificate serial number (serialNumber INTEGER of TBSCertificate asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the To Be Signed certificate signature (signature SEQUENCE of TBSCertificate asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the the To Be Signed certificate subject (subject CHOICE of TBSCertificate asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the the To Be Signed certificate subject unique identifier (subjectUniqueID BIT STRING of TBSCertificate asn.1 SEQUENCE).static final shortField identifier for the DER-encoding of the To Be Signed certificate version (version INTEGER of the TBSCertificate asn.1 SEQUENCE). -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getExtension(byte[] oid, short offset, short length) Get the extension matching an OID or return null if not found.voidAllows to access extensions of this certificate and trigger theX509Certificate.ExtensionHandlerinterface for each extension.byte[]getField(short field) Gets a field value or null if not found.shortGets the version (version number) value from the certificate.Methods inherited from interface Certificate
getPublicKey, getType, verifyModifier and TypeMethodDescriptionGets the public key from this certificate.shortgetType()Gets the type of this certificatebooleanVerifies that this certificate was signed using the private key that corresponds to the specified public key.
-
Field Details
-
FIELD_TBS_VERSION
static final short FIELD_TBS_VERSIONField identifier for the DER-encoding of the To Be Signed certificate version (version INTEGER of the TBSCertificate asn.1 SEQUENCE).- See Also:
-
FIELD_TBS_SERIAL_NUMBER
static final short FIELD_TBS_SERIAL_NUMBERField identifier for the INTEGER DER-encoding of the To Be Signed certificate serial number (serialNumber INTEGER of TBSCertificate asn.1 SEQUENCE).- See Also:
-
FIELD_TBS_SIGNATURE_ALG
static final short FIELD_TBS_SIGNATURE_ALGField identifier for the DER-encoding of the To Be Signed certificate signature (signature SEQUENCE of TBSCertificate asn.1 SEQUENCE).- See Also:
-
FIELD_TBS_ISSUER
static final short FIELD_TBS_ISSUERField identifier for the DER-encoding of the the To Be Signed certificate issuer (issuer CHOICE of TBSCertificate asn.1 SEQUENCE).- See Also:
-
FIELD_TBS_NOT_AFTER
static final short FIELD_TBS_NOT_AFTERField identifier for the DER-encoding of the notAfter validity time (notAfter CHOICE of the Validity asn.1 SEQUENCE).- See Also:
-
FIELD_TBS_NOT_BEFORE
static final short FIELD_TBS_NOT_BEFOREField identifier for the DER-encoding of the notBefore validity time (notBefore CHOICE of the Validity asn.1 SEQUENCE).- See Also:
-
FIELD_TBS_SUBJECT
static final short FIELD_TBS_SUBJECTField identifier for the DER-encoding of the the To Be Signed certificate subject (subject CHOICE of TBSCertificate asn.1 SEQUENCE).- See Also:
-
FIELD_TBS_PUBLIC_KEY_INFO
static final short FIELD_TBS_PUBLIC_KEY_INFOField identifier for the DER-encoding of the the To Be Signed certificate public key info (subjectPublicKeyInfo SEQUENCE of TBSCertificate asn.1 SEQUENCE).- See Also:
-
FIELD_TBS_ISSUER_UID
static final short FIELD_TBS_ISSUER_UIDField identifier for the DER-encoding of the the To Be Signed certificate issuer unique identifier (issuerUniqueID BIT STRING of TBSCertificate asn.1 SEQUENCE).- See Also:
-
FIELD_TBS_SUBJECT_UID
static final short FIELD_TBS_SUBJECT_UIDField identifier for the DER-encoding of the the To Be Signed certificate subject unique identifier (subjectUniqueID BIT STRING of TBSCertificate asn.1 SEQUENCE).- See Also:
-
FIELD_CERTIFICATE_TBS
static final short FIELD_CERTIFICATE_TBSField identifier for the DER-encoding of the certificate To Be Signed (TBSCertificate SEQUENCE of Certificate asn.1 SEQUENCE).- See Also:
-
FIELD_CERTIFICATE_SIGNATURE_ALG
static final short FIELD_CERTIFICATE_SIGNATURE_ALGField identifier for the DER-encoding of the certificate signature algorithm (signatureAlgorithm SEQUENCE of Certificate asn.1 SEQUENCE).- See Also:
-
FIELD_CERTIFICATE_SIGNATURE
static final short FIELD_CERTIFICATE_SIGNATUREField identifier for the DER-encoding of the certificate signature (signature BIT STRING of Certificate asn.1 SEQUENCE).- See Also:
-
-
Method Details
-
getVersion
short getVersion()Gets the version (version number) value from the certificate. The ASN.1 definition for this is:version [0] EXPLICIT Version DEFAULT v1
Version ::= INTEGER { v1(0), v2(1), v3(2) }
- Returns:
- the version number, i.e. 1, 2 or 3.
-
getField
Gets a field value or null if not found.- Parameters:
field- the field identifier- Returns:
- returns a temporary read-only array view on the specified field. May be null.
- Throws:
CertificateException- - with INVALID_PARAM reason if the requested field constant is unknown
-
getExtension
Get the extension matching an OID or return null if not found. The return value is the DER-encoded SEQUENCE of an extension (Extension asn.1 SEQUENCE) including the OID itself.- Parameters:
oid- input buffer of the extension OID which is the DER-encoded OBJECT IDENTIFIER of the extension ID (extnID of the Extension asn.1 SEQUENCE)offset- offset of the OID within the input bufferlength- length of the OID within the input buffer- Returns:
- returns a temporary read-only array view of the specified extension. May be
null. - Throws:
CertificateException- with the following reason code:- CertificateException.INVALID_ENCODING if the OID encoding is incorrect.
-
getExtensions
Allows to access extensions of this certificate and trigger theX509Certificate.ExtensionHandlerinterface for each extension.Note that after a call to this method, the value returned by the implementation of
X509Certificate.ExtensionHandler.onExtension(byte[], boolean, byte[])each time the related handler is triggered is ignored.- Parameters:
handler- the handler to trigger for each extension- Throws:
CertificateException- with the following reason codes:- CertificateException.PARSER_HANDLER_EXCEPTION if an exception has been thrown by the
X509Certificate.ExtensionHandlerhandler.
- CertificateException.PARSER_HANDLER_EXCEPTION if an exception has been thrown by the
-