我正在设置 Deno 服务器来处理 HTTPS 请求,我使用自签名证书来完成这项工作。\n为此使用了以下代码:
\n\nimport { serveTLS } from "https://deno.land/std/http/server.ts";\n\nconst body = new TextEncoder().encode("Hello HTTPS");\nconst options = {\n hostname: "localhost",\n port: 443,\n certFile: "./path/to/localhost.crt",\n keyFile: "./path/to/localhost.key",\n};\n// Top-level await supported\nfor await (const req of serveTLS(options)) {\n req.respond({ body });\n}\nRun Code Online (Sandbox Code Playgroud)\n\n我运行此代码为:deno --allow-net --allow-read app.ts\n我收到以下错误:
ERROR RS - rustls::session:571 - TLS alert received: Message {\n typ: Alert,\n version: TLSv1_3,\n payload: Alert(\n AlertMessagePayload {\n level: Fatal,\n description: BadCertificate,\n },\n ),\n}\nerror: Uncaught InvalidData: received fatal alert: BadCertificate\n\xe2\x96\xba $deno$/errors.ts:57:13\n at InvalidData ($deno$/errors.ts:135:5)\n at constructError ($deno$/errors.ts:57:13)\n at unwrapResponse ($deno$/dispatch_json.ts:41:12)\n at sendAsync ($deno$/dispatch_json.ts:96:10)\nRun Code Online (Sandbox Code Playgroud)\n\n是否可以在 Deno 中使用自签名证书?\n出了什么问题以及如何修复它?
\n