tls キーを設定して TLS を構成します。key と cert の両方が必須です。key は秘密鍵の内容である必要があります。cert は発行された証明書の内容である必要があります。Bun.file() を使用して内容を読み取ります。
ts
const server = Bun.serve({
fetch: request => new Response("Welcome to Bun!"),
tls: {
cert: Bun.file("cert.pem"),
key: Bun.file("key.pem"),
},
});デフォルトでは、Bun は Mozilla によって厳選された既知のルート CA のリストを信頼します。このリストを上書きするには、証明書の配列を 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")],
},
});