Class CertificateUtils


  • public final class CertificateUtils
    extends Object
    Utility class offering convenience methods for certificates.

    Requires Bouncy Castle.

    • Field Detail

      • ACME_VALIDATION

        public static final org.bouncycastle.asn1.ASN1ObjectIdentifier ACME_VALIDATION
        The acmeValidation object identifier.
        Since:
        2.1
    • Method Detail

      • createTestRootCertificate

        public static X509Certificate createTestRootCertificate​(String subject,
                                                                Instant notBefore,
                                                                Instant notAfter,
                                                                KeyPair keypair)
        Creates a self-signed root certificate.

        The generated certificate is only meant for testing purposes!

        Parameters:
        subject - This certificate's subject X.500 name.
        notBefore - Instant before which the certificate is not valid.
        notAfter - Instant after which the certificate is not valid.
        keypair - KeyPair that is to be used for this certificate.
        Returns:
        Generated X509Certificate
        Since:
        2.8
      • createTestCertificate

        public static X509Certificate createTestCertificate​(org.bouncycastle.pkcs.PKCS10CertificationRequest csr,
                                                            Instant notBefore,
                                                            Instant notAfter,
                                                            X509Certificate issuer,
                                                            PrivateKey issuerPrivateKey)
        Creates a signed end entity certificate from the given CSR.

        This method is only meant for testing purposes! Do not use it in a real-world CA implementation.

        Do not assume that real-world certificates have a similar structure. It's up to the discretion of the CA which distinguished names, validity dates, extensions and other parameters are transferred from the CSR to the generated certificate.

        Parameters:
        csr - CSR to create the certificate from
        notBefore - Instant before which the certificate is not valid.
        notAfter - Instant after which the certificate is not valid.
        issuer - The issuer's X509Certificate.
        issuerPrivateKey - PrivateKey of the issuer. This is not the private key the CSR was signed with.
        Returns:
        Generated X509Certificate
        Since:
        2.8