Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var client = netlib.connect(PORT_NUMBER, function(){
var sslcontext = crypto.createCredentials();
var pair = tlslib.createSecurePair(sslcontext, false);
pair.encrypted.pipe(client);
client.pipe(pair.encrypted);
pair.fd = client.fd;
pair.on("secure", function(){
pair.cleartext.on("data", function(chunk){
test.equal(chunk.toString(), "TEST\r\n");
pair.cleartext.end();
});
});
});
var client = netlib.connect(PORT_NUMBER, function(){
var sslcontext = crypto.createCredentials();
var pair = tlslib.createSecurePair(sslcontext, false);
pair.encrypted.pipe(client);
client.pipe(pair.encrypted);
pair.fd = client.fd;
pair.on("secure", function(){
test.ok(1, "secure connection");
});
});
const server = net.Server(common.mustCall(function(raw) {
const pair = tls.createSecurePair(null, true, false, false);
pair.on('error', function() {});
pair.ssl.setSNICallback(common.mustCall(function() {
raw.destroy();
server.close();
}));
require('_tls_legacy').pipe(pair, raw);
})).listen(0, function() {
tls.connect({
function securePair(conn, client) {
const serverCtx = tls.createSecureContext(options);
const serverPair = tls.createSecurePair(serverCtx, true, true, false);
conn.pipe(serverPair.encrypted);
serverPair.encrypted.pipe(conn);
serverPair.on('error', (error) => {
throw new Error(`Pair error: ${error}`);
});
serverPair.cleartext.pipe(client);
}