11cb0ef41Sopenharmony_ci// Flags: --expose-internals 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.hasCrypto) common.skip('missing crypto'); 51cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// Test enableTrace: option for TLS. 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst assert = require('assert'); 101cb0ef41Sopenharmony_ciconst { fork } = require('child_process'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciif (process.argv[2] === 'test') 131cb0ef41Sopenharmony_ci return test(); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst binding = require('internal/test/binding').internalBinding; 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciif (!binding('tls_wrap').HAVE_SSL_TRACE) 181cb0ef41Sopenharmony_ci return common.skip('no SSL_trace() compiled into openssl'); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciconst child = fork(__filename, ['test'], { silent: true }); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_cilet stderr = ''; 231cb0ef41Sopenharmony_cichild.stderr.setEncoding('utf8'); 241cb0ef41Sopenharmony_cichild.stderr.on('data', (data) => stderr += data); 251cb0ef41Sopenharmony_cichild.on('close', common.mustCall(() => { 261cb0ef41Sopenharmony_ci assert.match(stderr, /Received Record/); 271cb0ef41Sopenharmony_ci assert.match(stderr, /ClientHello/); 281cb0ef41Sopenharmony_ci})); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci// For debugging and observation of actual trace output. 311cb0ef41Sopenharmony_cichild.stderr.pipe(process.stderr); 321cb0ef41Sopenharmony_cichild.stdout.pipe(process.stdout); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_cichild.on('exit', common.mustCall((code) => { 351cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 361cb0ef41Sopenharmony_ci})); 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_cifunction test() { 391cb0ef41Sopenharmony_ci const { 401cb0ef41Sopenharmony_ci connect, keys 411cb0ef41Sopenharmony_ci } = require(fixtures.path('tls-connect')); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci connect({ 441cb0ef41Sopenharmony_ci client: { 451cb0ef41Sopenharmony_ci checkServerIdentity: (servername, cert) => { }, 461cb0ef41Sopenharmony_ci ca: `${keys.agent1.cert}\n${keys.agent6.ca}`, 471cb0ef41Sopenharmony_ci }, 481cb0ef41Sopenharmony_ci server: { 491cb0ef41Sopenharmony_ci cert: keys.agent6.cert, 501cb0ef41Sopenharmony_ci key: keys.agent6.key, 511cb0ef41Sopenharmony_ci enableTrace: true, 521cb0ef41Sopenharmony_ci }, 531cb0ef41Sopenharmony_ci }, common.mustCall((err, pair, cleanup) => { 541cb0ef41Sopenharmony_ci pair.client.conn.enableTrace(); 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci return cleanup(); 571cb0ef41Sopenharmony_ci })); 581cb0ef41Sopenharmony_ci} 59