aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/http/tls.md
blob: a7e59dfea90b0cd7ed0b009ad88040e35d4fd17e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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")],
  },
});
```
pan>Fix lazy loading internal streamsGravatar Jarred Sumner 13-360/+424 2022-06-15direct streams mostly workjarred/directGravatar Jarred Sumner 26-1167/+1782 2022-06-15wip direct streamsGravatar Jarred Sumner 24-398/+2276 2022-06-12ArrayBufferSink works and it's good.Gravatar Jarred Sumner 26-170/+2054 2022-06-12Fix build issueGravatar Jarred Sumner 2-0/+6 2022-06-12Delete broken submoduleGravatar Jarred Sumner 1-0/+0 2022-06-10Update Dockerfile.baseGravatar Jarred Sumner 1-1/+1 2022-06-10Update WebKitGravatar Jarred Sumner 1-0/+0 2022-06-10Update event_loop.zigGravatar Jarred Sumner 1-0/+1 2022-06-10Missing errno on linuxGravatar Jarred Sumner 1-3/+1 2022-06-10Update js_parser.zigGravatar Jarred Sumner 1-21/+200 2022-06-10Update MakefileGravatar Jarred Sumner 1-4/+4 2022-06-10wip fix linux buildGravatar Jarred Sumner 1-9/+11 2022-06-10Don't show generic crash info when given invalid bunfig.tomlGravatar Jarred Sumner 1-0/+4 2022-06-10Update logger.zigGravatar Jarred Sumner 1-0/+4 2022-06-10Show tracingGravatar Jarred Sumner 1-1/+1 2022-06-10Update bunfig.zigGravatar Jarred Sumner 1-0/+1 2022-06-10Update jest.zigGravatar Jarred Sumner 1-6/+9 2022-06-09Update bun.d.tsGravatar Jarred Sumner 1-2/+5 2022-06-09Add typesGravatar Jarred Sumner 1-2/+32 2022-06-09`new Response(stream).arrayBuffer()` + 3 moreGravatar Jarred Sumner 16-39/+478 2022-06-09fix some memory leaks with stringsGravatar Jarred Sumner 4-28/+45 2022-06-09Support console.log(myBigInt)Gravatar Jarred Sumner 1-1/+6 2022-06-09Fix defaultProps with JSX optimizationGravatar Jarred Sumner 6-34/+73 2022-06-09small perf improvements to encodingGravatar Jarred Sumner 1-43/+37 2022-06-07Update event_loop.zigGravatar Jarred Sumner 1-1/+2