Is there an easy way to read tls certificate and key from a filesystem?

I do the following:
if (Deno.env.has("TLS_CERT_PATH") && Deno.env.has("TLS_PKEY_PATH")) {
const tlsCert = Deno.readFileSync(Deno.env.get("TLS_CERT_PATH"));
const tlsPkey = Deno.readFileSync(Deno.env.get("TLS_PKEY_PATH"));
serverOptions = { cert: tlsCert, key: tlsPkey };
}
if (Deno.env.has("TLS_CERT_PATH") && Deno.env.has("TLS_PKEY_PATH")) {
const tlsCert = Deno.readFileSync(Deno.env.get("TLS_CERT_PATH"));
const tlsPkey = Deno.readFileSync(Deno.env.get("TLS_PKEY_PATH"));
serverOptions = { cert: tlsCert, key: tlsPkey };
}
and it doesn't work because apparently it wants a string, not a uint8array. I don't know what's a good way to get a string from a uint8array or to read a string from fs.
1 Reply
ioB
ioB10mo ago
Deno.readTextFileSync

Did you find this page helpful?