HTTPS Oak Deno

I want to run Deno Oak over Https in local. I use OpenSsl to create cert and key. But no works.
No description
DAH
Deno AI Helper57d ago
To run an Oak server over HTTPS in Deno, you'll need to use the listenTls function provided by Deno to create a secure server. The documentation indicates that you can now pass the certificate and private key directly as strings to Deno.listenTls(), which is a more flexible approach than using file paths. Here's a step-by-step guide based on the documentation: 1. Ensure you have your certificate (localhost.crt) and private key (localhost.key) ready. You mentioned you've created these using OpenSSL, which is the correct approach. 2. Read your certificate and key files into strings using Deno.readTextFile. This is an asynchronous operation, so you'll need to await the results. 3. Use these strings to create a TLS listener with Deno.listenTls. Here's an example code snippet from the documentation that demonstrates how to do this:
import { Application } from "https://deno.land/x/oak/mod.ts";

const app = new Application();

// Add your Oak middleware and routes here

const cert = await Deno.readTextFile("path/to/localhost.crt");
const key = await Deno.readTextFile("path/to/localhost.key");

const listener = Deno.listenTls({
hostname: "localhost",
port: 443, // Standard HTTPS port
cert,
key,
});

for await (const conn of listener) {
app.handle(conn);
}
import { Application } from "https://deno.land/x/oak/mod.ts";

const app = new Application();

// Add your Oak middleware and routes here

const cert = await Deno.readTextFile("path/to/localhost.crt");
const key = await Deno.readTextFile("path/to/localhost.key");

const listener = Deno.listenTls({
hostname: "localhost",
port: 443, // Standard HTTPS port
cert,
key,
});

for await (const conn of listener) {
app.handle(conn);
}
Make sure to replace "path/to/localhost.crt" and "path/to/localhost.key" with the actual paths to your certificate and key files. If you're still encountering issues, ensure that: - The certificate and key are correctly formatted and match each other. - The paths to the certificate and key files are correct. - You have the necessary permissions to read the certificate and key files. If you've followed these steps and are still facing problems, please provide more details
DAH
Deno AI Helper57d ago
about the error messages or issues you're encountering, and I'll do my best to assist you further. 🦕
I
ivandpf57d ago
No description
I
ivandpf57d ago
... I want a person not a bot I create with mkcert now and no validate certificate
More Posts
WebSocket proxy Deno.createHttpClientIs it possible to use proxy for web socket connections in Deno?How to feed a ReadableStream / async Generator into a Response object?``` Bun.serve({ async fetch(req) { return new Response( async function* stredeno_core manual tick/poll(Learning the ropes of deno_core) Two related questions: - If I create a JsRuntime, and call `polIs there any way to know currently running has been deno compiled?Can something like Deno.compiled be used to determine this?Testing API serverI'm trying to setup an API server using deno and am trying to figure out what the canonical way of tDebugging high (string) heap usageI was observing relatively high memory usage in my deno applications (web-applications). I haven't aVS Code integration is brokenHi all. Just opened my Deno project in VS Code and got: `Cannot set workspace settings: invalid typfollow up action after respond to the requestCurrently, i have this for my http interaction discord bot ```ts // ping.js execute(api: API, interaHow to apply @deno-types on a dynamic import```ts // @deno-types="npm:@types/react-dom@18/client" const { hydrateRoot: hydrate } = (await impCache fresh deps on docker problemI have a brand new fresh project with only the default deps and when i try to put my app in a dockerDeno fmt with verbatimModuleSyntax?Currently Deno fmt sorts *verbatim imports* alphabetically, this is conflicting with the *Organize IHow to use private remote modules hosted on GitHub on Deno Deploy?According to [Private Modules and Repositories](https://docs.deno.com/runtime/manual/basics/modules/Encryption using Deno KV and OAuth?I'm creating a note-taking app using most of Deno's tools. I was thinking about encrypting user noteDeno is not seeing a projectIt seems deno is not seeing a project i am using. Project link: https://github.com/Swifter1243/ReMa