Skip to main content
Bun supports TLS out of the box, powered by BoringSSL. Enable TLS by passing in a value for key and cert; both are required to enable TLS.
The key and cert fields expect the contents of your TLS key and certificate, not a path to it. This can be a string, BunFile, TypedArray, or Buffer.

Passphrase

If your private key is encrypted with a passphrase, provide a value for passphrase to decrypt it.

CA Certificates

Optionally, you can override the trusted CA certificates by passing a value for ca. By default, the server will trust the list of well-known CAs curated by Mozilla. When ca is specified, the Mozilla list is overwritten.

Diffie-Hellman

To override Diffie-Hellman parameters:

Server name indication (SNI)

To configure the server name indication (SNI) for the server, set the serverName field in the tls object.
To allow multiple server names, pass an array of objects to tls, each with a serverName field.