From 98e2f6d50b6b0e077a1fae99ee77ed5ce7f33aef Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Sun, 21 Apr 2024 11:58:59 +1000 Subject: [PATCH] FUTURE(ext/net): remove `Deno.ListenTlsOptions.(keyFile|certFile)` (#23271) Towards #23089 --------- Signed-off-by: Asher Gomez --- ext/net/02_tls.js | 7 +++++++ tests/specs/future/runtime_api/main.js | 13 +++++++++++++ tests/specs/future/runtime_api/main.out | 1 + 3 files changed, 21 insertions(+) diff --git a/ext/net/02_tls.js b/ext/net/02_tls.js index 4216cbe22b..b77b92e263 100644 --- a/ext/net/02_tls.js +++ b/ext/net/02_tls.js @@ -153,6 +153,13 @@ function loadTlsKeyPair(api, { keyFile, privateKey, }) { + if (internals.future) { + certFile = undefined; + certChain = undefined; + keyFile = undefined; + privateKey = undefined; + } + // Check for "pem" format if (keyFormat !== undefined && keyFormat !== "pem") { throw new TypeError('If `keyFormat` is specified, it must be "pem"'); diff --git a/tests/specs/future/runtime_api/main.js b/tests/specs/future/runtime_api/main.js index a79185e925..b44291218f 100644 --- a/tests/specs/future/runtime_api/main.js +++ b/tests/specs/future/runtime_api/main.js @@ -92,6 +92,19 @@ try { } } +// Note: this could throw with a `Deno.errors.NotFound` error if `keyFile` and +// `certFile` were used. +try { + Deno.listenTls({ port: tlsPort, keyFile: "foo", certFile: "foo" }); +} catch (error) { + if ( + error instanceof Deno.errors.InvalidData && + error.message === + "Deno.listenTls requires a key: Error creating TLS certificate" + ) { + console.log("Deno.ListenTlsOptions.(keyFile|certFile) do nothing"); + } +} console.log("Deno.customInspect is", Deno.customInspect); self.close(); diff --git a/tests/specs/future/runtime_api/main.out b/tests/specs/future/runtime_api/main.out index 1bc41c026e..07b5884950 100644 --- a/tests/specs/future/runtime_api/main.out +++ b/tests/specs/future/runtime_api/main.out @@ -34,4 +34,5 @@ Deno.TlsListener.prototype.rid is undefined Deno.TlsConn.prototype.rid is undefined Deno.FsWatcher.prototype.rid is undefined Deno.FsFile constructor is illegal +Deno.ListenTlsOptions.(keyFile|certFile) do nothing Deno.customInspect is undefined