Skip to content

createSelfSignedCertificate

createSelfSignedCertificate(subjectAltNames?): Promise<SelfSignedCertificate>

Defined in: tls/create-self-signed-certificate.ts:28

Create a throwaway self-signed certificate for localhost and 127.0.0.1, for a test that needs a TLS server. Trust it explicitly on the client side (ca: cert); nothing is installed anywhere.

Uses the openssl command, which must be on the PATH, with an ECDSA P-256 key valid for one day. Takes tens of milliseconds: create one per suite.

readonly string[] = ...

The names the certificate is valid for, in OpenSSL’s subjectAltName syntax. Defaults to localhost and 127.0.0.1; a test of name verification passes others.

Promise<SelfSignedCertificate>

When openssl is missing or fails.