<p dir="auto">I created a self-signed certificate with OpenSSL and started a TLS server with Deno. I was able to start the server without problems, but when sending a request from the browser the server crashed. I received two different error messages from Firefox and Chrome. It is clear that a self-signed certificate is not suitable for production systems, but usually it can be temporarily bypassed in the browser by setting "Advanced" and "I'll take the risk".</p>
<p dir="auto">I created the certificates with the following command:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="openssl req  -nodes -new -x509 -keyout server.key -out server.cert"><pre class="notranslate"><code class="notranslate">openssl req  -nodes -new -x509 -keyout server.key -out server.cert
</code></pre></div>
<p dir="auto">Then created a <a href="https://gist.github.com/Caesar2011/eba3b46e944ef221100f6be79c0e3e7d">minimal working example</a>:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { serveTLS } from &quot;https://deno.land/x/std@0.52.0/http/server.ts&quot;;

const options = {
  port: 3000,
  hostname: &quot;0.0.0.0&quot;,
  certFile: &quot;./server.cert&quot;,
  keyFile: &quot;./server.key&quot;
};

const s = serveTLS(options);

for await (const req of s) {
  req.respond({body: &quot;Hello World&quot;});
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">serveTLS</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"https://deno.land/x/std@0.52.0/http/server.ts"</span><span class="pl-kos">;</span>

<span class="pl-k">const</span> <span class="pl-s1">options</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">port</span>: <span class="pl-c1">3000</span><span class="pl-kos">,</span>
  <span class="pl-c1">hostname</span>: <span class="pl-s">"0.0.0.0"</span><span class="pl-kos">,</span>
  <span class="pl-c1">certFile</span>: <span class="pl-s">"./server.cert"</span><span class="pl-kos">,</span>
  <span class="pl-c1">keyFile</span>: <span class="pl-s">"./server.key"</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-k">const</span> <span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-en">serveTLS</span><span class="pl-kos">(</span><span class="pl-s1">options</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">for</span> <span class="pl-k">await</span> <span class="pl-kos">(</span><span class="pl-k">const</span> <span class="pl-s1">req</span> <span class="pl-k">of</span> <span class="pl-s1">s</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">respond</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">body</span>: <span class="pl-s">"Hello World"</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">And ran it with the following command:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ deno run --allow-all https://gist.githubusercontent.com/Caesar2011/eba3b46e944ef221100f6be79c0e3e7d/raw/15bd52963d6a27787ed9261f1b78d8a05bf5058e/deno_bad_certificate.ts"><pre class="notranslate">$ deno run --allow-all https://gist.githubusercontent.com/Caesar2011/eba3b46e944ef221100f6be79c0e3e7d/raw/15bd52963d6a27787ed9261f1b78d8a05bf5058e/deno_bad_certificate.ts</pre></div>
<p dir="auto">My version of Deno:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ deno --version
deno 1.0.1
v8 8.4.300
typescript 3.9.2"><pre class="notranslate">$ deno --version
deno 1.0.1
v8 8.4.300
typescript 3.9.2</pre></div>
<p dir="auto">In a browser, the server is then accessible at:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="https://0.0.0.0:3000/"><pre class="notranslate"><code class="notranslate">https://0.0.0.0:3000/
</code></pre></div>
<p dir="auto">Server crash/shutdown after a call in Firefox (76.0.1, Ubuntu):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR RS - rustls::session:514 - TLS alert received: Message {
    typ: Alert,
    version: TLSv1_3,
    payload: Alert(
        AlertMessagePayload {
            level: Fatal,
            description: BadCertificate,
        },
    ),
}
error: Uncaught InvalidData: received fatal alert: BadCertificate
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
    at async TLSListenerImpl.accept ($deno$/tls.ts:31:17)
    at async Server.acceptConnAndIterateHttpRequests (https://deno.land/x/std@0.52.0/http/server.ts:221:14)
    at async MuxAsyncIterator.callIteratorNext (https://deno.land/x/std@0.52.0/async/mux_async_iterator.ts:28:29)"><pre class="notranslate"><code class="notranslate">ERROR RS - rustls::session:514 - TLS alert received: Message {
    typ: Alert,
    version: TLSv1_3,
    payload: Alert(
        AlertMessagePayload {
            level: Fatal,
            description: BadCertificate,
        },
    ),
}
error: Uncaught InvalidData: received fatal alert: BadCertificate
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
    at async TLSListenerImpl.accept ($deno$/tls.ts:31:17)
    at async Server.acceptConnAndIterateHttpRequests (https://deno.land/x/std@0.52.0/http/server.ts:221:14)
    at async MuxAsyncIterator.callIteratorNext (https://deno.land/x/std@0.52.0/async/mux_async_iterator.ts:28:29)
</code></pre></div>
<p dir="auto">Server crash/shutdown after a call in Chromium (81.0.4044.138, Ubuntu):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR RS - rustls::session:514 - TLS alert received: Message {
    typ: Alert,
    version: TLSv1_3,
    payload: Alert(
        AlertMessagePayload {
            level: Fatal,
            description: CertificateUnknown,
        },
    ),
}
error: Uncaught InvalidData: received fatal alert: CertificateUnknown
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
    at async TLSListenerImpl.accept ($deno$/tls.ts:31:17)
    at async Server.acceptConnAndIterateHttpRequests (https://deno.land/x/std@0.52.0/http/server.ts:221:14)
    at async MuxAsyncIterator.callIteratorNext (https://deno.land/x/std@0.52.0/async/mux_async_iterator.ts:28:29)"><pre class="notranslate"><code class="notranslate">ERROR RS - rustls::session:514 - TLS alert received: Message {
    typ: Alert,
    version: TLSv1_3,
    payload: Alert(
        AlertMessagePayload {
            level: Fatal,
            description: CertificateUnknown,
        },
    ),
}
error: Uncaught InvalidData: received fatal alert: CertificateUnknown
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
    at async TLSListenerImpl.accept ($deno$/tls.ts:31:17)
    at async Server.acceptConnAndIterateHttpRequests (https://deno.land/x/std@0.52.0/http/server.ts:221:14)
    at async MuxAsyncIterator.callIteratorNext (https://deno.land/x/std@0.52.0/async/mux_async_iterator.ts:28:29)
</code></pre></div>
<p dir="auto">Here's a quick reproducer, given:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import ajv from &quot;https://cdn.skypack.dev/ajv@v8.6.3?dts&quot;;"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">ajv</span> <span class="pl-k">from</span> <span class="pl-s">"https://cdn.skypack.dev/ajv@v8.6.3?dts"</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><code class="notranslate">deno</code> (<code class="notranslate">eval</code>, <code class="notranslate">run</code>, <code class="notranslate">cache</code>, etc.) will hang forever, with 100% CPU usage:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="docker run -it --rm  denoland/deno:1.15.3 deno eval 'import ajv from &quot;https://cdn.skypack.dev/ajv@v8.6.3?dts&quot;' "><pre class="notranslate">docker run -it --rm  denoland/deno:1.15.3 deno <span class="pl-c1">eval</span> <span class="pl-s"><span class="pl-pds">'</span>import ajv from "https://cdn.skypack.dev/ajv@v8.6.3?dts"<span class="pl-pds">'</span></span> </pre></div>
<p dir="auto">This used to work perfectly with <code class="notranslate">1.14.x</code> and below:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="docker run -it --rm  denoland/deno:1.14.3 deno eval 'import ajv from &quot;https://cdn.skypack.dev/ajv@v8.6.3?dts&quot;' "><pre class="notranslate">docker run -it --rm  denoland/deno:1.14.3 deno <span class="pl-c1">eval</span> <span class="pl-s"><span class="pl-pds">'</span>import ajv from "https://cdn.skypack.dev/ajv@v8.6.3?dts"<span class="pl-pds">'</span></span> </pre></div>
<p dir="auto">This seemed to exhibit the behavior of an infinite loop or recursion.</p>