1'use strict'; 2 3// Test asynchronous SNI+OCSP on TLSSocket created with `server` set to 4// `net.Server` instead of `tls.Server` 5 6const common = require('../common'); 7 8if (!common.hasCrypto) 9 common.skip('missing crypto'); 10 11const assert = require('assert'); 12const net = require('net'); 13const tls = require('tls'); 14const fixtures = require('../common/fixtures'); 15 16const key = fixtures.readKey('agent1-key.pem'); 17const cert = fixtures.readKey('agent1-cert.pem'); 18 19const server = net.createServer(common.mustCall((s) => { 20 const tlsSocket = new tls.TLSSocket(s, { 21 isServer: true, 22 server: server, 23 24 secureContext: tls.createSecureContext({ key, cert }), 25 26 SNICallback: common.mustCall((hostname, callback) => { 27 assert.strictEqual(hostname, 'test.test'); 28 29 callback(null, null); 30 }) 31 }); 32 33 tlsSocket.on('secure', common.mustCall(() => { 34 tlsSocket.end(); 35 server.close(); 36 })); 37})).listen(0, () => { 38 const opts = { 39 servername: 'test.test', 40 port: server.address().port, 41 rejectUnauthorized: false, 42 requestOCSP: true 43 }; 44 45 tls.connect(opts, function() { 46 this.end(); 47 }); 48}); 49