Skip to content

Tls

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 JSTime.file() to read the contents.

const server = JSTime.serve({
fetch: (request) => new Response("Welcome to JSTime!"),
tls: {
cert: JSTime.file("cert.pem"),
key: JSTime.file("key.pem"),
},
});

By default JSTime trusts the default Mozilla-curated list of well-known root CAs. To override this list, pass an array of certificates as ca.

const server = JSTime.serve({
fetch: (request) => new Response("Welcome to JSTime!"),
tls: {
cert: JSTime.file("cert.pem"),
key: JSTime.file("key.pem"),
ca: [JSTime.file("ca1.pem"), JSTime.file("ca2.pem")],
},
});