diff options
author | 2023-07-26 14:59:39 -0700 | |
---|---|---|
committer | 2023-07-26 14:59:39 -0700 | |
commit | 4c89c60867591b50e0b31bf5009fd5ad6a3cebe1 (patch) | |
tree | fc1d2f47309c0345a850933496baa40d94bfdcbb /docs/guides/http/tls.md | |
parent | 6bfee02301a2e2a0b79339974af0445eb5a2688f (diff) | |
download | bun-4c89c60867591b50e0b31bf5009fd5ad6a3cebe1.tar.gz bun-4c89c60867591b50e0b31bf5009fd5ad6a3cebe1.tar.zst bun-4c89c60867591b50e0b31bf5009fd5ad6a3cebe1.zip |
Add files (#3826)
Diffstat (limited to 'docs/guides/http/tls.md')
-rw-r--r-- | docs/guides/http/tls.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/docs/guides/http/tls.md b/docs/guides/http/tls.md new file mode 100644 index 000000000..a7e59dfea --- /dev/null +++ b/docs/guides/http/tls.md @@ -0,0 +1,30 @@ +--- +name: Configure TLS on an HTTP server +--- + +Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](/docs/api/file-io#reading-files-bun-file) to read the contents. + +```ts +const server = Bun.serve({ + fetch: (request) => new Response("Welcome to Bun!"), + tls: { + cert: Bun.file("cert.pem"), + key: Bun.file("key.pem"), + }, +}); +``` + +--- + +By default Bun trusts the default Mozilla-curated list of well-known root CAs. To override this list, pass an array of certificates as `ca`. + +```ts +const server = Bun.serve({ + fetch: (request) => new Response("Welcome to Bun!"), + tls: { + cert: Bun.file("cert.pem"), + key: Bun.file("key.pem"), + ca: [Bun.file("ca1.pem"), Bun.file("ca2.pem")], + }, +}); +``` |