org.apache.commons.ssl

## Class Certificates

- java.lang.Object
- - org.apache.commons.ssl.Certificates

    public class Certificates
    extends java.lang.Object

Since:
  19-Aug-2005
Author:
  Credit Union Central of British Columbia, www.cucbc.com, juliusdavies@cucbc.com

### Nested Class Summary

Nested Classes
`private static class` `Certificates.CRLHolder`
`static interface` `Certificates.SerializableComparator`

### Field Summary

Fields
`static java.security.cert.CertificateFactory` `CF`
`static Certificates.SerializableComparator` `COMPARE_BY_EXPIRY`
`private static java.util.HashMap` `crl_cache`
`static java.lang.String` `CRL_EXTENSION`
`private static java.text.DateFormat` `DF`
`static java.lang.String` `LINE_ENDING`
`static java.lang.String` `OCSP_EXTENSION`

### Constructor Summary

Constructors
Constructor and Description
`Certificates()`

### Method Summary

Methods
`static void` `checkCRL(java.security.cert.X509Certificate cert)`
`static java.lang.String` `getCN(java.security.cert.X509Certificate cert)`
`static java.lang.String[]` `getCNs(java.security.cert.X509Certificate cert)`
`static java.util.List` `getCRLs(java.security.cert.X509Extension cert)`
`static java.lang.String[]` `getDNSSubjectAlts(java.security.cert.X509Certificate cert)` Extracts the array of SubjectAlt DNS names from an X509Certificate.
`static java.math.BigInteger` `getFingerprint(byte[] x509)`
`static java.math.BigInteger` `getFingerprint(java.security.cert.X509Certificate x509)`
`static void` `main(java.lang.String[] args)`
`static java.lang.String` `toPEMString(java.security.cert.X509Certificate cert)`
`static java.lang.String` `toString(byte[] x509Encoded)`
`static java.lang.String` `toString(java.security.cert.X509Certificate cert)`
`static java.lang.String` `toString(java.security.cert.X509Certificate cert, boolean htmlStyle)`
`static java.security.cert.Certificate[]` `trimChain(java.security.cert.Certificate[] chain)` Trims off any null entries on the array.
`static java.security.cert.X509Certificate[]` `x509ifyChain(java.security.cert.Certificate[] chain)` Returns a chain of type X509Certificate[].

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### CF

    public static final java.security.cert.CertificateFactory CF

#### LINE_ENDING

    public static final java.lang.String LINE_ENDING

#### crl_cache

    private static final java.util.HashMap crl_cache

#### CRL_EXTENSION

    public static final java.lang.String CRL_EXTENSION

See Also:
  Constant Field Values

#### OCSP_EXTENSION

    public static final java.lang.String OCSP_EXTENSION

See Also:
  Constant Field Values

#### DF

    private static final java.text.DateFormat DF

#### COMPARE_BY_EXPIRY

    public static final Certificates.SerializableComparator COMPARE_BY_EXPIRY

### Constructor Detail

#### Certificates

    public Certificates()

### Method Detail

#### toPEMString

    public static java.lang.String toPEMString(java.security.cert.X509Certificate cert)
                                        throws java.security.cert.CertificateEncodingException

Throws:
  `java.security.cert.CertificateEncodingException`

#### toString

    public static java.lang.String toString(byte[] x509Encoded)

#### toString

    public static java.lang.String toString(java.security.cert.X509Certificate cert)

#### toString

    public static java.lang.String toString(java.security.cert.X509Certificate cert,
                            boolean htmlStyle)

#### getCRLs

    public static java.util.List getCRLs(java.security.cert.X509Extension cert)

#### checkCRL

    public static void checkCRL(java.security.cert.X509Certificate cert)
                         throws java.security.cert.CertificateException

Throws:
  `java.security.cert.CertificateException`

#### getFingerprint

    public static java.math.BigInteger getFingerprint(java.security.cert.X509Certificate x509)
                                               throws java.security.cert.CertificateEncodingException

Throws:
  `java.security.cert.CertificateEncodingException`

#### getFingerprint

    public static java.math.BigInteger getFingerprint(byte[] x509)
                                               throws java.security.cert.CertificateEncodingException

Throws:
  `java.security.cert.CertificateEncodingException`

#### getCN

    public static java.lang.String getCN(java.security.cert.X509Certificate cert)

#### getCNs

    public static java.lang.String[] getCNs(java.security.cert.X509Certificate cert)

#### getDNSSubjectAlts

    public static java.lang.String[] getDNSSubjectAlts(java.security.cert.X509Certificate cert)

Extracts the array of SubjectAlt DNS names from an X509Certificate. Returns null if there aren't any.

Note: Java doesn't appear able to extract international characters from the SubjectAlts. It can only extract international characters from the CN field.

(Or maybe the version of OpenSSL I'm using to test isn't storing the international characters correctly in the SubjectAlts?).

Parameters:
  `cert` - X509Certificate
Returns:
  Array of SubjectALT DNS names stored in the certificate.

#### trimChain

    public static java.security.cert.Certificate[] trimChain(java.security.cert.Certificate[] chain)

Trims off any null entries on the array. Returns a shrunk array.

Parameters:
  `chain` - X509Certificate[] chain to trim
Returns:
  Shrunk array with all trailing null entries removed.

#### x509ifyChain

    public static java.security.cert.X509Certificate[] x509ifyChain(java.security.cert.Certificate[] chain)

Returns a chain of type X509Certificate[].

Parameters:
  `chain` - Certificate[] chain to cast to X509Certificate[]
Returns:
  chain of type X509Certificate[].

#### main

    public static void main(java.lang.String[] args)
                     throws java.lang.Exception

Throws:
  `java.lang.Exception`