java.lang.Object | |||
↳ | java.security.cert.Certificate | ||
↳ | java.security.cert.X509Certificate | ||
↳ | sun.security.x509.X509CertImpl |
The X509CertImpl class represents an X.509 certificate. These certificates are widely used to support authentication and other functionality in Internet security systems. Common applications include Privacy Enhanced Mail (PEM), Transport Layer Security (SSL), code signing for trusted software distribution, and Secure Electronic Transactions (SET). There is a commercial infrastructure ready to manage large scale deployments of X.509 identity certificates.
These certificates are managed and vouched for by Certificate Authorities (CAs). CAs are services which create certificates by placing data in the X.509 standard format and then digitally signing that data. Such signatures are quite difficult to forge. CAs act as trusted third parties, making introductions between agents who have no direct knowledge of each other. CA certificates are either signed by themselves, or by some other CA such as a "root" CA.
RFC 1422 is very informative, though it does not describe much of the recent work being done with X.509 certificates. That includes a 1996 version (X.509v3) and a variety of enhancements being made to facilitate an explosion of personal certificates used as "Internet Drivers' Licences", or with SET for credit card transactions.
More recent work includes the IETF PKIX Working Group efforts, especially RFC2459.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ALG_ID | ||||||||||
String | INFO | ||||||||||
String | ISSUER_DN | ||||||||||
String | NAME | Public attribute names. | |||||||||
String | PUBLIC_KEY | ||||||||||
String | SERIAL_ID | ||||||||||
String | SIG | ||||||||||
String | SIGNATURE | ||||||||||
String | SIGNED_CERT | ||||||||||
String | SIG_ALG | ||||||||||
String | SUBJECT_DN | The following are defined for ease-of-use. | |||||||||
String | VERSION |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
algId | |||||||||||
info | |||||||||||
signature |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Default constructor.
| |||||||||||
Unmarshals a certificate from its encoded form, parsing the
encoded bytes.
| |||||||||||
unmarshals an X.509 certificate from an input stream.
| |||||||||||
Construct an initialized X509 Certificate.
| |||||||||||
Unmarshal a certificate from its encoded form, parsing a DER value.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Checks that the certificate is currently valid, i.e.
| |||||||||||
Checks that the specified date is within the certificate's
validity period, or basically if the certificate would be
valid at the specified date/time.
| |||||||||||
Delete the requested attribute from the certificate.
| |||||||||||
DER encode this object onto an output stream.
| |||||||||||
Appends the certificate to an output stream.
| |||||||||||
Return the requested attribute from the certificate.
| |||||||||||
Get AuthorityKeyIdentifier extension
| |||||||||||
Get the certificate constraints path length from the
the critical BasicConstraints extension, (oid = 2.5.29.19).
| |||||||||||
Get BasicConstraints extension
| |||||||||||
Get CRLDistributionPoints extension
| |||||||||||
Get CertificatePoliciesExtension
| |||||||||||
Gets a Set of the extension(s) marked CRITICAL in the
certificate.
| |||||||||||
Return an enumeration of names of attributes existing within this
attribute.
| |||||||||||
Returns the encoded form of this certificate.
| |||||||||||
Returned the encoding as an uncloned byte array.
| |||||||||||
Returned the encoding of the given certificate for internal use.
| |||||||||||
This method are the overridden implementation of
getExtendedKeyUsage method in X509Certificate in the Sun
provider.
| |||||||||||
This static method is the default implementation of the
getExtendedKeyUsage method in X509Certificate.
| |||||||||||
Get ExtendedKeyUsage extension
| |||||||||||
Gets the extension identified by the given ObjectIdentifier
| |||||||||||
Gets the DER encoded extension identified by the given
oid String.
| |||||||||||
Get IssuerAlternativeName extension
| |||||||||||
This static method is the default implementation of the
getIssuerAlternaitveNames method in X509Certificate.
| |||||||||||
This method are the overridden implementation of
getIssuerAlternativeNames method in X509Certificate in the Sun
provider.
| |||||||||||
Gets the issuer distinguished name from the certificate.
| |||||||||||
Gets the Issuer Unique Identity from the certificate.
| |||||||||||
Get issuer name as X500Principal.
| |||||||||||
Extract the issuer X500Principal from an X509Certificate.
| |||||||||||
Get a boolean array representing the bits of the KeyUsage extension,
(oid = 2.5.29.15).
| |||||||||||
Return the name of this attribute.
| |||||||||||
Get NameConstraints extension
| |||||||||||
Gets a Set of the extension(s) marked NON-CRITICAL in the
certificate.
| |||||||||||
Gets the notAfter date from the validity period of the certificate.
| |||||||||||
Gets the notBefore date from the validity period of the certificate.
| |||||||||||
Get PolicyConstraints extension
| |||||||||||
Get PolicyMappingsExtension extension
| |||||||||||
Get PrivateKeyUsage extension
| |||||||||||
Gets the publickey from this certificate.
| |||||||||||
Gets the serial number from the certificate.
| |||||||||||
Gets the serial number from the certificate as
a SerialNumber object.
| |||||||||||
Gets the signature algorithm name for the certificate
signature algorithm.
| |||||||||||
Gets the signature algorithm OID string from the certificate.
| |||||||||||
Gets the DER encoded signature algorithm parameters from this
certificate's signature algorithm.
| |||||||||||
Gets the raw Signature bits from the certificate.
| |||||||||||
Get SubjectAlternativeName extension
| |||||||||||
This method are the overridden implementation of
getSubjectAlternativeNames method in X509Certificate in the Sun
provider.
| |||||||||||
This static method is the default implementation of the
getSubjectAlternaitveNames method in X509Certificate.
| |||||||||||
Gets the subject distinguished name from the certificate.
| |||||||||||
Get SubjectKeyIdentifier extension
| |||||||||||
Gets the Subject Unique Identity from the certificate.
| |||||||||||
Extract the subject X500Principal from an X509Certificate.
| |||||||||||
Get subject name as X500Principal.
| |||||||||||
Gets the DER encoded certificate informations, the
tbsCertificate from this certificate. | |||||||||||
Gets the version number from the certificate.
| |||||||||||
Return true if a critical extension is found that is
not supported, otherwise return false.
| |||||||||||
Utility method to test if a certificate is self-issued.
| |||||||||||
Utility method to test if a certificate is self-signed.
| |||||||||||
Set the requested attribute in the certificate.
| |||||||||||
Creates an X.509 certificate, and signs it using the given key
(associating a signature algorithm and an X.500 name).
| |||||||||||
Creates an X.509 certificate, and signs it using the given key
(associating a signature algorithm and an X.500 name).
| |||||||||||
Utility method to convert an arbitrary instance of X509Certificate
to a X509CertImpl.
| |||||||||||
Returns a printable representation of the certificate.
| |||||||||||
Throws an exception if the certificate was not signed using the
verification key provided.
| |||||||||||
Throws an exception if the certificate was not signed using the
verification key provided.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
The following are defined for ease-of-use. These are the most frequently retrieved attributes.
Default constructor.
Unmarshals a certificate from its encoded form, parsing the encoded bytes. This form of constructor is used by agents which need to examine and use certificate contents. That is, this is one of the more commonly used constructors. Note that the buffer must include only a certificate, and no "garbage" may be left at the end. If you need to ignore data at the end of a certificate, use another constructor.
certData | the encoded bytes, with no trailing padding. |
---|
CertificateException | on parsing and initialization errors. |
---|
unmarshals an X.509 certificate from an input stream. If the certificate is RFC1421 hex-encoded, then it must begin with the line X509Factory.BEGIN_CERT and end with the line X509Factory.END_CERT.
in | an input stream holding at least one certificate that may be either DER-encoded or RFC1421 hex-encoded version of the DER-encoded certificate. |
---|
CertificateException | on parsing and initialization errors. |
---|
Construct an initialized X509 Certificate. The certificate is stored in raw form and has to be signed to be useful.
Unmarshal a certificate from its encoded form, parsing a DER value. This form of constructor is used by agents which need to examine and use certificate contents.
derVal | the der value containing the encoded cert. |
---|
CertificateException | on parsing and initialization errors. |
---|
Checks that the certificate is currently valid, i.e. the current time is within the specified validity period.
CertificateExpiredException | if the certificate has expired. |
---|---|
CertificateNotYetValidException | if the certificate is not yet valid. |
Checks that the specified date is within the certificate's validity period, or basically if the certificate would be valid at the specified date/time.
date | the Date to check against to see if this certificate is valid at that date/time. |
---|
CertificateExpiredException | if the certificate has expired
with respect to the date supplied. |
---|---|
CertificateNotYetValidException | if the certificate is not
yet valid with respect to the date supplied.
|
Delete the requested attribute from the certificate.
name | the name of the attribute. |
---|
CertificateException | on invalid attribute identifier. |
---|---|
IOException | on other errors. |
DER encode this object onto an output stream.
Implements the DerEncoder
interface.
out | the output stream on which to write the DER encoding. |
---|
IOException | on encoding error. |
---|
Appends the certificate to an output stream.
out | an input stream to which the certificate is appended. |
---|
CertificateEncodingException | on encoding errors. |
---|
Return the requested attribute from the certificate. Note that the X509CertInfo is not cloned for performance reasons. Callers must ensure that they do not modify it. All other attributes are cloned.
name | the name of the attribute. |
---|
CertificateParsingException | on invalid attribute identifier. |
---|
Get AuthorityKeyIdentifier extension
Get the certificate constraints path length from the the critical BasicConstraints extension, (oid = 2.5.29.19).
Get BasicConstraints extension
Get CRLDistributionPoints extension
Get CertificatePoliciesExtension
Gets a Set of the extension(s) marked CRITICAL in the certificate. In the returned set, each extension is represented by its OID string.
Return an enumeration of names of attributes existing within this attribute.
Returns the encoded form of this certificate. It is assumed that each certificate type would have only a single form of encoding; for example, X.509 certificates would be encoded as ASN.1 DER.
CertificateEncodingException | if an encoding error occurs. |
---|
Returned the encoding as an uncloned byte array. Callers must guarantee that they neither modify it nor expose it to untrusted code.
CertificateEncodingException |
---|
Returned the encoding of the given certificate for internal use. Callers must guarantee that they neither modify it nor expose it to untrusted code. Uses getEncodedInternal() if the certificate is instance of X509CertImpl, getEncoded() otherwise.
CertificateEncodingException |
---|
This method are the overridden implementation of getExtendedKeyUsage method in X509Certificate in the Sun provider. It is better performance-wise since it returns cached values.
CertificateParsingException |
---|
This static method is the default implementation of the getExtendedKeyUsage method in X509Certificate. A X509Certificate provider generally should overwrite this to provide among other things caching for better performance.
CertificateParsingException |
---|
Get ExtendedKeyUsage extension
Gets the extension identified by the given ObjectIdentifier
oid | the Object Identifier value for the extension. |
---|
Gets the DER encoded extension identified by the given oid String.
oid | the Object Identifier value for the extension. |
---|
Get IssuerAlternativeName extension
This static method is the default implementation of the getIssuerAlternaitveNames method in X509Certificate. A X509Certificate provider generally should overwrite this to provide among other things caching for better performance.
CertificateParsingException |
---|
This method are the overridden implementation of getIssuerAlternativeNames method in X509Certificate in the Sun provider. It is better performance-wise since it returns cached values.
Collection
of issuer alternative
names (or null
)CertificateParsingException |
---|
Gets the issuer distinguished name from the certificate.
Gets the Issuer Unique Identity from the certificate.
Get issuer name as X500Principal. Overrides implementation in X509Certificate with a slightly more efficient version that is also aware of X509CertImpl mutability.
X500Principal
representing the issuer
distinguished nameExtract the issuer X500Principal from an X509Certificate. Called from java.security.cert.X509Certificate.getIssuerX500Principal().
Get a boolean array representing the bits of the KeyUsage extension, (oid = 2.5.29.15).
Get NameConstraints extension
Gets a Set of the extension(s) marked NON-CRITICAL in the certificate. In the returned set, each extension is represented by its OID string.
Gets the notAfter date from the validity period of the certificate.
Gets the notBefore date from the validity period of the certificate.
Get PolicyConstraints extension
Get PolicyMappingsExtension extension
Get PrivateKeyUsage extension
Gets the serial number from the certificate.
Gets the serial number from the certificate as a SerialNumber object.
Gets the signature algorithm name for the certificate signature algorithm. For example, the string "SHA-1/DSA" or "DSS".
Gets the signature algorithm OID string from the certificate. For example, the string "1.2.840.10040.4.3"
Gets the DER encoded signature algorithm parameters from this certificate's signature algorithm.
Gets the raw Signature bits from the certificate.
Get SubjectAlternativeName extension
This method are the overridden implementation of getSubjectAlternativeNames method in X509Certificate in the Sun provider. It is better performance-wise since it returns cached values.
Collection
of subject alternative
names (or null
)CertificateParsingException |
---|
This static method is the default implementation of the getSubjectAlternaitveNames method in X509Certificate. A X509Certificate provider generally should overwrite this to provide among other things caching for better performance.
CertificateParsingException |
---|
Gets the subject distinguished name from the certificate.
Get SubjectKeyIdentifier extension
Gets the Subject Unique Identity from the certificate.
Extract the subject X500Principal from an X509Certificate. Called from java.security.cert.X509Certificate.getSubjectX500Principal().
Get subject name as X500Principal. Overrides implementation in X509Certificate with a slightly more efficient version that is also aware of X509CertImpl mutability.
X500Principal
representing the subject
distinguished nameGets the DER encoded certificate informations, the
tbsCertificate
from this certificate.
This can be used to verify the signature independently.
CertificateEncodingException | if an encoding error occurs. |
---|
Gets the version number from the certificate.
Return true if a critical extension is found that is not supported, otherwise return false.
Utility method to test if a certificate is self-issued. This is the case iff the subject and issuer X500Principals are equal.
Utility method to test if a certificate is self-signed. This is the case iff the subject and issuer X500Principals are equal AND the certificate's subject public key can be used to verify the certificate. In case of exception, returns false.
Set the requested attribute in the certificate.
name | the name of the attribute. |
---|---|
obj | the value of the attribute. |
CertificateException | on invalid attribute identifier. |
---|---|
IOException | on encoding error of attribute. |
Creates an X.509 certificate, and signs it using the given key (associating a signature algorithm and an X.500 name). This operation is used to implement the certificate generation functionality of a certificate authority.
key | the private key used for signing. |
---|---|
algorithm | the name of the signature algorithm used. |
provider | the name of the provider. |
NoSuchAlgorithmException | on unsupported signature algorithms. |
---|---|
InvalidKeyException | on incorrect key. |
NoSuchProviderException | on incorrect provider. |
SignatureException | on signature errors. |
CertificateException | on encoding errors. |
Creates an X.509 certificate, and signs it using the given key (associating a signature algorithm and an X.500 name). This operation is used to implement the certificate generation functionality of a certificate authority.
key | the private key used for signing. |
---|---|
algorithm | the name of the signature algorithm used. |
InvalidKeyException | on incorrect key. |
---|---|
NoSuchAlgorithmException | on unsupported signature algorithms. |
NoSuchProviderException | if there's no default provider. |
SignatureException | on signature errors. |
CertificateException | on encoding errors. |
Utility method to convert an arbitrary instance of X509Certificate to a X509CertImpl. Does a cast if possible, otherwise reparses the encoding.
CertificateException |
---|
Returns a printable representation of the certificate. This does not contain all the information available to distinguish this from any other certificate. The certificate must be fully constructed before this function may be called.
Throws an exception if the certificate was not signed using the verification key provided. Successfully verifying a certificate does not indicate that one should trust the entity which it represents.
key | the public key used for verification. |
---|---|
sigProvider | the name of the provider. |
NoSuchAlgorithmException | on unsupported signature algorithms. |
---|---|
InvalidKeyException | on incorrect key. |
NoSuchProviderException | on incorrect provider. |
SignatureException | on signature errors. |
CertificateException | on encoding errors. |
Throws an exception if the certificate was not signed using the verification key provided. Successfully verifying a certificate does not indicate that one should trust the entity which it represents.
key | the public key used for verification. |
---|
InvalidKeyException | on incorrect key. |
---|---|
NoSuchAlgorithmException | on unsupported signature algorithms. |
NoSuchProviderException | if there's no default provider. |
SignatureException | on signature errors. |
CertificateException | on encoding errors. |