mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
b32732b1ee
PR-URL: https://github.com/nodejs/node/pull/34111 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
const { duplexPair } = require('stream');
|
|
const assert = require('assert');
|
|
const { TLSSocket, connect } = require('tls');
|
|
|
|
const key = fixtures.readKey('agent1-key.pem');
|
|
const cert = fixtures.readKey('agent1-cert.pem');
|
|
const ca = fixtures.readKey('ca1-cert.pem');
|
|
|
|
const [ clientSide, serverSide ] = duplexPair();
|
|
|
|
const clientTLS = connect({
|
|
socket: clientSide,
|
|
ca,
|
|
host: 'agent1' // Hostname from certificate
|
|
});
|
|
const serverTLS = new TLSSocket(serverSide, {
|
|
isServer: true,
|
|
key,
|
|
cert,
|
|
ca
|
|
});
|
|
|
|
assert.strictEqual(clientTLS.connecting, false);
|
|
assert.strictEqual(serverTLS.connecting, false);
|
|
|
|
clientTLS.on('secureConnect', common.mustCall(() => {
|
|
clientTLS.write('foobar', common.mustCall(() => {
|
|
assert.strictEqual(serverTLS.read().toString(), 'foobar');
|
|
assert.strictEqual(clientTLS._handle.writeQueueSize, 0);
|
|
}));
|
|
assert.ok(clientTLS._handle.writeQueueSize > 0);
|
|
}));
|