使用自签名证书在Deno上设置HTTPS?

使用自签名证书在Deno上设置HTTPS?,deno,Deno,我正在设置一个Deno服务器来处理HTTPS请求,我使用自签名证书来完成这项工作。 用于此目的的以下代码: import { serveTLS } from "https://deno.land/std/http/server.ts"; const body = new TextEncoder().encode("Hello HTTPS"); const options = { hostname: "localhost", port: 443, certFile: "./path/

我正在设置一个Deno服务器来处理HTTPS请求,我使用自签名证书来完成这项工作。 用于此目的的以下代码:

import { serveTLS } from "https://deno.land/std/http/server.ts";

const body = new TextEncoder().encode("Hello HTTPS");
const options = {
  hostname: "localhost",
  port: 443,
  certFile: "./path/to/localhost.crt",
  keyFile: "./path/to/localhost.key",
};
// Top-level await supported
for await (const req of serveTLS(options)) {
  req.respond({ body });
}
我以如下方式运行此代码:
deno--allow-net--allow-read-app.ts
我发现以下错误:

ERROR RS - rustls::session:571 - TLS alert received: Message {
    typ: Alert,
    version: TLSv1_3,
    payload: Alert(
        AlertMessagePayload {
            level: Fatal,
            description: BadCertificate,
        },
    ),
}
error: Uncaught InvalidData: received fatal alert: BadCertificate
► $deno$/errors.ts:57:13
    at InvalidData ($deno$/errors.ts:135:5)
    at constructError ($deno$/errors.ts:57:13)
    at unwrapResponse ($deno$/dispatch_json.ts:41:12)
    at sendAsync ($deno$/dispatch_json.ts:96:10)
是否可以将自签名证书与Deno一起使用?
出了什么问题以及如何修复?

这是我的证书文件的一个问题,几乎相同的证书在nodejs中工作。
我创建了本地证书和密钥,而不是使用它,然后它工作了

解决此问题的另一种方法(来自上游rustls问题):@KevinQian是的,这一个看起来相关,我将查看并更新它。甚至无法达到我可以看到您的错误的程度,复制您的代码,使用我的本地自签名证书设置它(与我的节点服务器一起使用)。获取错误:
Uncaught PermissionDenied:Object.sendSync($deno$/ops/dispatch_json.ts:43:11)Object.listenTls($deno$/ops/dispatch_json.ts:72:10)Object.listenTls($deno$/ops/tls.ts:67:10)listenTls($deno$/tls.ts:51:22)serveTLS(server.ts:313:20)
源于锈迹,无法根据此处所写内容找到解决方案:@exside我的证书文件有问题,与nodejs使用的证书几乎相同。我创建了本地证书,而不是使用这个,然后它工作了!伊内特斯廷!谢谢你让我知道!