summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_tls_wrap.ts
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-08-11 17:27:41 +0530
committerGitHub <noreply@github.com>2023-08-11 11:57:41 +0000
commit33dc5d262288f4efae3077978f37f22338568b35 (patch)
treed4fdc4b6d9c7a6ab775754f5c1b923e5da04d7ab /ext/node/polyfills/_tls_wrap.ts
parent2f00b0add476bb151bc3a713da165296906cfc2a (diff)
fix(node): implement TLSSocket._start (#20120)
Closes https://github.com/denoland/deno/issues/19983 Closes https://github.com/denoland/deno/issues/18303 Closes https://github.com/denoland/deno/issues/16681 Closes https://github.com/denoland/deno/issues/19978
Diffstat (limited to 'ext/node/polyfills/_tls_wrap.ts')
-rw-r--r--ext/node/polyfills/_tls_wrap.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/node/polyfills/_tls_wrap.ts b/ext/node/polyfills/_tls_wrap.ts
index 39df239d0..416bd4136 100644
--- a/ext/node/polyfills/_tls_wrap.ts
+++ b/ext/node/polyfills/_tls_wrap.ts
@@ -26,6 +26,11 @@ import {
import { EventEmitter } from "node:events";
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
import { nextTick } from "ext:deno_node/_next_tick.ts";
+import { kHandle } from "ext:deno_node/internal/stream_base_commons.ts";
+import {
+ isAnyArrayBuffer,
+ isArrayBufferView,
+} from "ext:deno_node/internal/util/types.ts";
const kConnectOptions = Symbol("connect-options");
const kIsVerified = Symbol("verified");
@@ -71,7 +76,11 @@ export class TLSSocket extends net.Socket {
[kPendingSession]: any;
[kConnectOptions]: any;
ssl: any;
- _start: any;
+
+ _start() {
+ this[kHandle].afterConnect();
+ }
+
constructor(socket: any, opts: any = kEmptyObject) {
const tlsOptions = { ...opts };
@@ -84,6 +93,9 @@ export class TLSSocket extends net.Socket {
let caCerts = tlsOptions?.secureContext?.ca;
if (typeof caCerts === "string") caCerts = [caCerts];
+ else if (isArrayBufferView(caCerts) || isAnyArrayBuffer(caCerts)) {
+ caCerts = [new TextDecoder().decode(caCerts)];
+ }
tlsOptions.caCerts = caCerts;
super({
@@ -139,9 +151,9 @@ export class TLSSocket extends net.Socket {
handle.afterConnect = async (req: any, status: number) => {
try {
const conn = await Deno.startTls(handle[kStreamBaseField], options);
+ handle[kStreamBaseField] = conn;
tlssock.emit("secure");
tlssock.removeListener("end", onConnectEnd);
- handle[kStreamBaseField] = conn;
} catch {
// TODO(kt3k): Handle this
}