summaryrefslogtreecommitdiff
path: root/cli/tests/unit/tls_test.ts
diff options
context:
space:
mode:
authorEvan <96965321+0xIchigo@users.noreply.github.com>2023-08-14 20:11:12 -0400
committerGitHub <noreply@github.com>2023-08-15 00:11:12 +0000
commitece2a3de5b19588160634452638aa656218853c5 (patch)
tree55a42d0180942300fc22d3fdc70ca0a0c9b92cf8 /cli/tests/unit/tls_test.ts
parent625bd3905047173390eeaffd0ffcbb0bf340bb52 (diff)
fix(ext/net): implement a graceful error on an invalid SSL certificate (#20157)
The goal of this PR is to address issue #19520 where Deno panics when encountering an invalid SSL certificate. This PR achieves that goal by removing an `.expect()` statement and implementing a match statement on `tsl_config` (found in [/ext/net/ops_tsl.rs](https://github.com/denoland/deno/blob/e071382768fa57b5288a6a5ba90e73bf5870b169/ext/net/ops_tls.rs#L1058)) to check whether the desired configuration is valid --------- Co-authored-by: Matt Mastracci <matthew@mastracci.com>
Diffstat (limited to 'cli/tests/unit/tls_test.ts')
-rw-r--r--cli/tests/unit/tls_test.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/cli/tests/unit/tls_test.ts b/cli/tests/unit/tls_test.ts
index 1f0702f62..8162c53b5 100644
--- a/cli/tests/unit/tls_test.ts
+++ b/cli/tests/unit/tls_test.ts
@@ -1491,3 +1491,31 @@ Deno.test({
});
listener.close();
});
+
+Deno.test(
+ { permissions: { net: true, read: true } },
+ function listenTLSInvalidCert() {
+ assertThrows(() => {
+ Deno.listenTls({
+ hostname: "localhost",
+ port: 3500,
+ certFile: "cli/tests/testdata/tls/invalid.crt",
+ keyFile: "cli/tests/testdata/tls/localhost.key",
+ });
+ }, Deno.errors.InvalidData);
+ },
+);
+
+Deno.test(
+ { permissions: { net: true, read: true } },
+ function listenTLSInvalidKey() {
+ assertThrows(() => {
+ Deno.listenTls({
+ hostname: "localhost",
+ port: 3500,
+ certFile: "cli/tests/testdata/tls/localhost.crt",
+ keyFile: "cli/tests/testdata/tls/invalid.key",
+ });
+ }, Deno.errors.InvalidData);
+ },
+);