How Enable HTTPS localhost DENO?

I want to run Deno Oak over Https in local. I use OpenSsl/mkcert to create cert and key. But no works.
No description
DAH
Deno AI Helper56d ago
To enable HTTPS on localhost for your Deno Oak server, you'll need to use TLS certificates with Deno.listenTls(). Since you've already created a certificate and key using OpenSSL or mkcert, you should be able to use them directly in your Deno application. Here's a step-by-step guide based on the documentation: 1. Ensure that your certificate (localhost.crt) and private key (localhost.key) are in the correct format and located in a directory that your Deno application can access. 2. Use the Deno.listenTls() function to create a secure server. You'll need to provide the paths to your certificate and key files. Here's an example snippet from the documentation:
const server = Deno.listenTls({
hostname: "localhost",
port: 8443,
cert: await Deno.readTextFile("localhost.crt"),
key: await Deno.readTextFile("localhost.key"),
alpnProtocols: ["h2", "http/1.1"],
});
const server = Deno.listenTls({
hostname: "localhost",
port: 8443,
cert: await Deno.readTextFile("localhost.crt"),
key: await Deno.readTextFile("localhost.key"),
alpnProtocols: ["h2", "http/1.1"],
});
3. Handle the incoming connections using an async iterator or the .accept() method as shown in the documentation:
for await (const conn of server) {
// ...handle the connection...
}
for await (const conn of server) {
// ...handle the connection...
}
or
while (true) {
try {
const conn = await server.accept();
// ... handle the connection ...
} catch (err) {
// The listener has closed
break;
}
}
while (true) {
try {
const conn = await server.accept();
// ... handle the connection ...
} catch (err) {
// The listener has closed
break;
}
}
4. Integrate this with your Oak application by passing the connection to Oak's application handler. If you've followed these steps and it's still not working, here are a few things to check: - Ensure that the certificate and key files are readable and in the correct location. - Verify that the certificate and key are correctly formatted and match each other. - Check if there are any error messages in the console that could give you more information about the issue. - Make sure you're
DAH
Deno AI Helper56d ago
accessing your server using https://localhost:8443 in your browser or client. If you continue to face issues, you might want to share the specific error message or behavior you're encountering, so we can provide more targeted assistance. 🦕
I
ivandpf56d ago
I want a response of a person