diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-02-19 01:30:58 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-18 07:30:58 -0700 |
commit | 9a43a2b4959be288034ef0c43f638542de2028b8 (patch) | |
tree | a1a54e374b3616b9d4ebf318d71fa5c0f5931c9f /ext/net/02_tls.js | |
parent | 3c7057d5832bae61de7f5001df85d2505d6aa9db (diff) |
feat: `Deno.ConnectTlsOptions.{cert,key}` (#22274)
Towards #22197
Diffstat (limited to 'ext/net/02_tls.js')
-rw-r--r-- | ext/net/02_tls.js | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/ext/net/02_tls.js b/ext/net/02_tls.js index 25fbb521c..7fde7d12b 100644 --- a/ext/net/02_tls.js +++ b/ext/net/02_tls.js @@ -51,21 +51,49 @@ async function connectTls({ caCerts = [], certChain = undefined, privateKey = undefined, + cert = undefined, + key = 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.", + "Pass the cert file contents to the `Deno.ConnectTlsOptions.cert` option instead.", + ); + } + if (certChain !== undefined) { + internals.warnOnDeprecatedApi( + "Deno.ConnectTlsOptions.certChain", + new Error().stack, + "Use the `Deno.ConnectTlsOptions.cert` option instead.", + ); + } + if (privateKey !== undefined) { + internals.warnOnDeprecatedApi( + "Deno.ConnectTlsOptions.privateKey", + new Error().stack, + "Use the `Deno.ConnectTlsOptions.key` option instead.", ); } if (transport !== "tcp") { throw new TypeError(`Unsupported transport: '${transport}'`); } + if (certChain !== undefined && cert !== undefined) { + throw new TypeError( + "Cannot specify both `certChain` and `cert`", + ); + } + if (privateKey !== undefined && key !== undefined) { + throw new TypeError( + "Cannot specify both `privateKey` and `key`", + ); + } + cert ??= certChain; + key ??= privateKey; const { 0: rid, 1: localAddr, 2: remoteAddr } = await op_net_connect_tls( { hostname, port }, - { certFile, caCerts, certChain, privateKey, alpnProtocols }, + { certFile, caCerts, cert, key, alpnProtocols }, ); localAddr.transport = "tcp"; remoteAddr.transport = "tcp"; |