|
| 1 | +// Flags: --expose-internals |
| 2 | +'use strict'; |
| 3 | +constcommon=require('../common'); |
| 4 | +if(!common.hasCrypto)common.skip('missing crypto'); |
| 5 | +constfixtures=require('../common/fixtures'); |
| 6 | + |
| 7 | +// Test --trace-tls CLI flag. |
| 8 | + |
| 9 | +constassert=require('assert'); |
| 10 | +const{ fork }=require('child_process'); |
| 11 | + |
| 12 | +if(process.argv[2]==='test') |
| 13 | +returntest(); |
| 14 | + |
| 15 | +constbinding=require('internal/test/binding').internalBinding; |
| 16 | + |
| 17 | +if(!binding('tls_wrap').HAVE_SSL_TRACE) |
| 18 | +returncommon.skip('no SSL_trace() compiled into openssl'); |
| 19 | + |
| 20 | +constchild=fork(__filename,['test'],{ |
| 21 | +silent: true, |
| 22 | +execArgv: ['--trace-tls'] |
| 23 | +}); |
| 24 | + |
| 25 | +letstderr=''; |
| 26 | +child.stderr.setEncoding('utf8'); |
| 27 | +child.stderr.on('data',(data)=>stderr+=data); |
| 28 | +child.on('close',common.mustCall(()=>{ |
| 29 | +assert(/Warning:Enabling--trace-tlscanexposesensitive/.test(stderr)); |
| 30 | +assert(/ReceivedRecord/.test(stderr)); |
| 31 | +assert(/ClientHello/.test(stderr)); |
| 32 | +})); |
| 33 | + |
| 34 | +// For debugging and observation of actual trace output. |
| 35 | +child.stderr.pipe(process.stderr); |
| 36 | +child.stdout.pipe(process.stdout); |
| 37 | + |
| 38 | +child.on('exit',common.mustCall((code)=>{ |
| 39 | +assert.strictEqual(code,0); |
| 40 | +})); |
| 41 | + |
| 42 | +functiontest(){ |
| 43 | +const{ |
| 44 | + connect, keys |
| 45 | +}=require(fixtures.path('tls-connect')); |
| 46 | + |
| 47 | +connect({ |
| 48 | +client: { |
| 49 | +checkServerIdentity: (servername,cert)=>{}, |
| 50 | +ca: `${keys.agent1.cert}\n${keys.agent6.ca}`, |
| 51 | +}, |
| 52 | +server: { |
| 53 | +cert: keys.agent6.cert, |
| 54 | +key: keys.agent6.key |
| 55 | +}, |
| 56 | +},common.mustCall((err,pair,cleanup)=>{ |
| 57 | +returncleanup(); |
| 58 | +})); |
| 59 | +} |
0 commit comments