<p dir="auto">deno 1.0.0<br>
v8 8.4.300<br>
typescript 3.9.2</p>
<p dir="auto">In Deno, is there already a way to override the pedantic scrutiny that often causes self-signed SSL certificates to be deemed "Bad Certificates"?</p>
<p dir="auto">It seems that Deno security is so high that it blocks self-signed SSL certificates for vague reasons.</p>
<p dir="auto">Not all SSL certificates should be subjected to international banking standards. There are valid reasons for creating self-signed SSL certificates with (practically) never expiring expiration dates. Too many security zealots automatically frown upon self-signed certificates, but hear me out.</p>
<p dir="auto">Let's say you have two servers on a LAN, that serve each other with separate APIs. And, the only security you want, is to have encrypted data transfer between those two servers and nothing else. And, let's say these services (that these two servers provide) do NOT require internet to function.</p>
<p dir="auto">Let me ask you this. Why the <strong>hell</strong> would you want to authenticate the SSL certificate with a 3rd party internet resource? The internet itself now becomes an unneeded external dependency that could potentially bring your service to a halt if the internet goes down (for a service that otherwise needs zero internet).</p>
<p dir="auto">Well that's exactly what can happen, if deno has no way to override errors like this:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/151919/83202732-dba6a600-a10d-11ea-9a60-c4e06a0304e5.png"><img src="https://user-images.githubusercontent.com/151919/83202732-dba6a600-a10d-11ea-9a60-c4e06a0304e5.png" alt="badCertificate" style="max-width: 100%;"></a></p>
<p dir="auto">The above script and certificates are zipped here: <a href="https://github.com/denoland/deno/files/4698729/testDeno.zip">testDeno.zip</a></p>
<p dir="auto">The ssl certificates were generated with a command like this:<br>
<code class="notranslate">openssl req -nodes -new -x509 -keyout private.key -out server.cert -days 1825000 -subj "/C=US/ST=Texas/L=Houston/O=ChickenPeck Technologies/OU=Org/CN=localhost"</code></p>
<p dir="auto">I suspect the certificate is bad due to the extremely far off date to which it expires. It would be nice if the error went into more detail about the exact reason the certificate is a "bad certificate".</p>
<p dir="auto">However, even if that is the reason, I'd like the ability to override and ignore such pedantic scrutiny. I'm not going to use something that inconveniences me with a mandatory security level that is beyond what I want it to be.</p>
<p dir="auto">Also, why would you want to schedule, on your calendar, a date (one year from now) when your service will crash due to an expired certificate? Instead, I want the service I created to live on without interruption, without any certificate update maintenance, until I decide I want to update it. As the developer of these services, I should be able to prioritize "uninterruptible" over "unnecessarily secure".</p>
<p dir="auto">Is there already a way to override these type of certificate rejections? If not, I'm requesting it.</p>
<p dir="auto">Because <code class="notranslate">std/http/server.ts</code> uses <code class="notranslate">MuxAsyncIterator</code> to serve up requests, any errors thrown there cannot be caught:</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/denoland/deno/blob/e34a3b61f449cf6197b6d701770a85d9205c2a7b/std/http/server.ts#L235-L239">deno/std/http/server.ts</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 235 to 239
      in
      <a data-pjax="true" class="commit-tease-sha" href="/denoland/deno/commit/e34a3b61f449cf6197b6d701770a85d9205c2a7b">e34a3b6</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L235" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="235"></td>
          <td id="LC235" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-kos">[</span><span class="pl-smi">Symbol</span><span class="pl-kos">.</span><span class="pl-c1">asyncIterator</span><span class="pl-kos">]</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">AsyncIterableIterator</span><span class="pl-kos">&lt;</span><span class="pl-smi">ServerRequest</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L236" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="236"></td>
          <td id="LC236" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-k">const</span> <span class="pl-s1">mux</span>: <span class="pl-smi">MuxAsyncIterator</span><span class="pl-kos">&lt;</span><span class="pl-smi">ServerRequest</span><span class="pl-kos">&gt;</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-smi">MuxAsyncIterator</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L237" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="237"></td>
          <td id="LC237" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-s1">mux</span><span class="pl-kos">.</span><span class="pl-en">add</span><span class="pl-kos">(</span><span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-en">acceptConnAndIterateHttpRequests</span><span class="pl-kos">(</span><span class="pl-s1">mux</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L238" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="238"></td>
          <td id="LC238" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-k">return</span> <span class="pl-s1">mux</span><span class="pl-kos">.</span><span class="pl-en">iterate</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L239" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="239"></td>
          <td id="LC239" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-kos">}</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">The comments on <code class="notranslate">MuxAsyncIterator</code> make it clear that:</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/denoland/deno/blob/e34a3b61f449cf6197b6d701770a85d9205c2a7b/std/async/mux_async_iterator.ts#L9-L14">deno/std/async/mux_async_iterator.ts</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 9 to 14
      in
      <a data-pjax="true" class="commit-tease-sha" href="/denoland/deno/commit/e34a3b61f449cf6197b6d701770a85d9205c2a7b">e34a3b6</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L9" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="9"></td>
          <td id="LC9" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c">/** The MuxAsyncIterator class multiplexes multiple async iterators into a</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L10" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="10"></td>
          <td id="LC10" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c"> * single stream. It currently makes a few assumptions:</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L11" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="11"></td>
          <td id="LC11" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c"> * - The iterators do not throw.</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L12" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="12"></td>
          <td id="LC12" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c"> * - The final result (the value returned and not yielded from the iterator)</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L13" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="13"></td>
          <td id="LC13" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c"> *   does not matter; if there is any, it is discarded.</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L14" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="14"></td>
          <td id="LC14" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c"> */</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">And in situations where you have a TLS connection where the browser rejects the certificate, you end up with something like this with Deno dumping and no way to recover:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="error: Uncaught InvalidData: received corrupt message
    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/std@0.50.0/http/server.ts:221:14)
    at async MuxAsyncIterator.callIteratorNext (https://deno.land/std@0.50.0/async/mux_async_iterator.ts:28:29)"><pre class="notranslate"><code class="notranslate">error: Uncaught InvalidData: received corrupt message
    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/std@0.50.0/http/server.ts:221:14)
    at async MuxAsyncIterator.callIteratorNext (https://deno.land/std@0.50.0/async/mux_async_iterator.ts:28:29)
</code></pre></div>
<p dir="auto">We need a way to iterate that allows errors to be caught when iterating on HTTP server.</p>