diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-01-24 03:35:23 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 17:35:23 +0100 |
commit | 18a235e6088a43411bbeca79bae8bcc646f72104 (patch) | |
tree | 10443315b7dd69fdeb7b2d6e962bc05a5f5818ff /ext/net | |
parent | b0febea47f9a9aba70adbbe089e11cb6f1a69145 (diff) |
refactor: set removal version for `Deno.ListenTlsOptions.certFile`, `Deno.ListenTlsOptions.keyFile` and `Deno.ConnectTlsOptions.certFile` (#22026)
This change:
1. Sets the removal version for `Deno.ListenTlsOptions.certFile`,
`Deno.ListenTlsOptions.keyFile` and `Deno.ConnectTlsOptions.certFile`
for Deno v2, in favour of the `cert`, `key` and `caCerts` options,
respectively.
2. Replaces use of the deprecated options with the new recommended
options.
Towards #22021
Diffstat (limited to 'ext/net')
-rw-r--r-- | ext/net/02_tls.js | 23 | ||||
-rw-r--r-- | ext/net/lib.deno_net.d.ts | 19 |
2 files changed, 36 insertions, 6 deletions
diff --git a/ext/net/02_tls.js b/ext/net/02_tls.js index 6fa5bff20..e71bd77f5 100644 --- a/ext/net/02_tls.js +++ b/ext/net/02_tls.js @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { core, primordials } from "ext:core/mod.js"; +import { core, internals, primordials } from "ext:core/mod.js"; const { op_net_accept_tls, op_net_connect_tls, @@ -39,6 +39,13 @@ async function connectTls({ privateKey = undefined, alpnProtocols = undefined, }) { + if (certFile !== undefined) { + internals.warnOnDeprecatedApi( + "Deno.ConnectTlsOptions.certFile", + new Error().stack, + "Pass the cert file contents to the `Deno.ConnectTlsOptions.certChain` option instead.", + ); + } if (transport !== "tcp") { throw new TypeError(`Unsupported transport: '${transport}'`); } @@ -76,6 +83,20 @@ function listenTls({ if (transport !== "tcp") { throw new TypeError(`Unsupported transport: '${transport}'`); } + if (keyFile !== undefined) { + internals.warnOnDeprecatedApi( + "Deno.ListenTlsOptions.keyFile", + new Error().stack, + "Pass the key file contents to the `Deno.ListenTlsOptions.key` option instead.", + ); + } + if (certFile !== undefined) { + internals.warnOnDeprecatedApi( + "Deno.ListenTlsOptions.certFile", + new Error().stack, + "Pass the cert file contents to the `Deno.ListenTlsOptions.cert` option instead.", + ); + } const { 0: rid, 1: localAddr } = op_net_listen_tls( { hostname, port: Number(port) }, { cert, certFile, key, keyFile, alpnProtocols, reusePort }, diff --git a/ext/net/lib.deno_net.d.ts b/ext/net/lib.deno_net.d.ts index c019c8d61..e3051d6ad 100644 --- a/ext/net/lib.deno_net.d.ts +++ b/ext/net/lib.deno_net.d.ts @@ -174,13 +174,17 @@ declare namespace Deno { * `--allow-read`. * * @tags allow-read - * @deprecated This option is deprecated and will be removed in Deno 2.0. + * @deprecated Pass the certificate file contents directly to the + * {@linkcode Deno.ListenTlsOptions.cert} option instead. This option will + * be removed in Deno 2.0. */ certFile?: string; /** Server private key file. Requires `--allow-read`. * * @tags allow-read - * @deprecated This option is deprecated and will be removed in Deno 2.0. + * @deprecated Pass the key file contents directly to the + * {@linkcode Deno.ListenTlsOptions.key} option instead. This option will + * be removed in Deno 2.0. */ keyFile?: string; @@ -197,7 +201,11 @@ declare namespace Deno { * security). * * ```ts - * const lstnr = Deno.listenTls({ port: 443, certFile: "./server.crt", keyFile: "./server.key" }); + * using listener = Deno.listenTls({ + * port: 443, + * cert: Deno.readTextFileSync("./server.crt"), + * key: Deno.readTextFileSync("./server.key"), + * }); * ``` * * Requires `allow-net` permission. @@ -289,8 +297,9 @@ declare namespace Deno { /** * Server certificate file. * - * @deprecated This option is deprecated and will be removed in a future - * release. + * @deprecated Pass the cert file contents directly to the + * {@linkcode Deno.ConnectTlsOptions.caCerts} option instead. This option + * will be removed in Deno 2.0. */ certFile?: string; /** A list of root certificates that will be used in addition to the |