Skip to main content

createSecurePair

function createSecurePair
Jump to headingcreateSecurePair(
context?: SecureContext,
isServer?: boolean,
requestCert?: boolean,
rejectUnauthorized?: boolean,
): SecurePair
Deprecated

Deno compatibility

This symbol is currently not supported.

Creates a new secure pair object with two streams, one of which reads and writes the encrypted data and the other of which reads and writes the cleartext data. Generally, the encrypted stream is piped to/from an incoming encrypted data stream and the cleartext one is used as a replacement for the initial encrypted stream.

tls.createSecurePair() returns a tls.SecurePair object with cleartext and encrypted stream properties.

Using cleartext has the same API as TLSSocket.

The tls.createSecurePair() method is now deprecated in favor oftls.TLSSocket(). For example, the code:

pair = tls.createSecurePair(// ... );
pair.encrypted.pipe(socket);
socket.pipe(pair.encrypted);

can be replaced by:

secureSocket = tls.TLSSocket(socket, options);

where secureSocket has the same API as pair.cleartext.

Parameters Jump to heading

A secure context object as returned by tls.createSecureContext()

optional
Jump to headingisServer: boolean

true to specify that this TLS connection should be opened as a server.

optional
Jump to headingrequestCert: boolean

true to specify whether a server should request a certificate from a connecting client. Only applies when isServer is true.

optional
Jump to headingrejectUnauthorized: boolean

If not false a server automatically reject clients with invalid certificates. Only applies when isServer is true.

Return Type Jump to heading

Back to top