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.
3 Replies
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:
3. Handle the incoming connections using an async iterator or the .accept()
method as shown in the documentation:
or
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'reaccessing 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 want a response of a person