createCertificateSigningRequest
Creates a PKCS#10 Certificate Signing Request signed with the given private key.
The CSR embeds the public key's SPKI, the subject name, and any requested extensions as attributes. The signature proves possession of the private key.
ts
function createCertificateSigningRequest(
input: CreateCsrInput,
): Promise<CsrMaterial>Parameters
input:CreateCsrInput
Examples
ts
import { createCertificateSigningRequest } from 'micro509';
const keyPair = await crypto.subtle.generateKey(
{ name: 'ECDSA', namedCurve: 'P-256' },
true,
['sign', 'verify'],
);
const csr = await createCertificateSigningRequest({
subject: { commonName: 'example.com' },
publicKey: keyPair.publicKey,
signerPrivateKey: keyPair.privateKey,
extensions: { subjectAltNames: [{ type: 'dns', value: 'example.com' }] },
});
console.log(csr.pem);