PKI-Lite - v1.2.1
    Preparing search index...

    Builder class for creating PKCS#10 certificate signing requests (CSRs).

    This builder provides a fluent API for constructing CSRs with various options including subject, extensions, and signature algorithm.

    // Create a simple CSR
    const csr = await CertificateRequest.builder()
    .setSubject('CN=example.com, O=My Org, C=US')
    .setPublicKey(publicKey)
    .setPrivateKey(privateKey)
    .addKeyUsage({ digitalSignature: true, keyEncipherment: true })
    .addSubjectAltName('example.com', '*.example.com')
    .build()

    Implements

    Index

    Constructors

    Methods

    • Adds an Extended Key Usage extension to the CSR.

      Parameters

      • options: {
            clientAuth?: boolean;
            codeSigning?: boolean;
            emailProtection?: boolean;
            ocspSigning?: boolean;
            serverAuth?: boolean;
            timeStamping?: boolean;
        } & { [oid: string]: boolean }

        Extended key usage purposes

      Returns this

      This builder for chaining

      builder.addExtendedKeyUsage({
      serverAuth: true,
      clientAuth: true
      })
    • Adds a Subject Alternative Name extension to the CSR. Strings are automatically converted to DNS names.

      Parameters

      • ...altNames: (string | GeneralName)[]

        Alternative names for the subject (strings or GeneralName objects)

      Returns this

      This builder for chaining

      // Simple DNS names as strings
      builder.addSubjectAltName('example.com', '*.example.com')

      // Or use GeneralName objects for other types
      builder.addSubjectAltName(
      new GeneralName.dNSName({ value: 'example.com' }),
      new GeneralName.rfc822Name({ value: 'admin@example.com' })
      )