CertTemplateBuilder (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.asn1.crmf

## Class CertTemplateBuilder

- java.lang.Object
- - org.bouncycastle.asn1.crmf.CertTemplateBuilder

-     public class CertTemplateBuilder
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CertTemplateBuilder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `CertTemplate` | `build()` CertTemplate ::= SEQUENCE { version [0] Version OPTIONAL, serialNumber [1] INTEGER OPTIONAL, signingAlg [2] AlgorithmIdentifier OPTIONAL, issuer [3] Name OPTIONAL, validity [4] OptionalValidity OPTIONAL, subject [5] Name OPTIONAL, publicKey [6] SubjectPublicKeyInfo OPTIONAL, issuerUID [7] UniqueIdentifier OPTIONAL, subjectUID [8] UniqueIdentifier OPTIONAL, extensions [9] Extensions OPTIONAL }
    `CertTemplateBuilder` | `setExtensions(Extensions extens)`
    `CertTemplateBuilder` | `setExtensions(X509Extensions extens)` Deprecated. use method taking Extensions
    `CertTemplateBuilder` | `setIssuer(X500Name name)`
    `CertTemplateBuilder` | `setIssuerUID(DERBitString uid)` Sets the issuer unique ID (deprecated in X.509v3)
    `CertTemplateBuilder` | `setPublicKey(SubjectPublicKeyInfo spki)`
    `CertTemplateBuilder` | `setSerialNumber(ASN1Integer ser)`
    `CertTemplateBuilder` | `setSigningAlg(AlgorithmIdentifier aid)`
    `CertTemplateBuilder` | `setSubject(X500Name name)`
    `CertTemplateBuilder` | `setSubjectUID(DERBitString uid)` Sets the subject unique ID (deprecated in X.509v3)
    `CertTemplateBuilder` | `setValidity(OptionalValidity v)`
    `CertTemplateBuilder` | `setVersion(int ver)` Sets the X.509 version.

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

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

- - ### Constructor Detail

    - #### CertTemplateBuilder

          public CertTemplateBuilder()

  - ### Method Detail

    - #### setVersion

          public CertTemplateBuilder setVersion(int ver)

      Sets the X.509 version. Note: for X509v3, use 2 here.

    - #### setSerialNumber

          public CertTemplateBuilder setSerialNumber(ASN1Integer ser)

    - #### setSigningAlg

          public CertTemplateBuilder setSigningAlg(AlgorithmIdentifier aid)

    - #### setIssuer

          public CertTemplateBuilder setIssuer(X500Name name)

    - #### setValidity

          public CertTemplateBuilder setValidity(OptionalValidity v)

    - #### setSubject

          public CertTemplateBuilder setSubject(X500Name name)

    - #### setPublicKey

          public CertTemplateBuilder setPublicKey(SubjectPublicKeyInfo spki)

    - #### setIssuerUID

          public CertTemplateBuilder setIssuerUID(DERBitString uid)

      Sets the issuer unique ID (deprecated in X.509v3)

    - #### setSubjectUID

          public CertTemplateBuilder setSubjectUID(DERBitString uid)

      Sets the subject unique ID (deprecated in X.509v3)

    - #### setExtensions

          public CertTemplateBuilder setExtensions(X509Extensions extens)

      Deprecated. use method taking Extensions

    - #### setExtensions

          public CertTemplateBuilder setExtensions(Extensions extens)

    - #### build

          public CertTemplate build()

            CertTemplate ::= SEQUENCE {
                version      [0] Version               OPTIONAL,
                serialNumber [1] INTEGER               OPTIONAL,
                signingAlg   [2] AlgorithmIdentifier   OPTIONAL,
                issuer       [3] Name                  OPTIONAL,
                validity     [4] OptionalValidity      OPTIONAL,
                subject      [5] Name                  OPTIONAL,
                publicKey    [6] SubjectPublicKeyInfo  OPTIONAL,
                issuerUID    [7] UniqueIdentifier      OPTIONAL,
                subjectUID   [8] UniqueIdentifier      OPTIONAL,
                extensions   [9] Extensions            OPTIONAL }

      Returns:
        a basic ASN.1 object representation.