11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciif (!common.hasCrypto) 41cb0ef41Sopenharmony_ci common.skip('missing crypto'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ciconst tls = require('tls'); 81cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst options = { 111cb0ef41Sopenharmony_ci pfx: [ 121cb0ef41Sopenharmony_ci { 131cb0ef41Sopenharmony_ci buf: fixtures.readKey('agent1.pfx'), 141cb0ef41Sopenharmony_ci passphrase: 'sample' 151cb0ef41Sopenharmony_ci }, 161cb0ef41Sopenharmony_ci fixtures.readKey('ec.pfx'), 171cb0ef41Sopenharmony_ci ] 181cb0ef41Sopenharmony_ci}; 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciconst ciphers = []; 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciconst server = tls.createServer(options, function(conn) { 231cb0ef41Sopenharmony_ci conn.end('ok'); 241cb0ef41Sopenharmony_ci}).listen(0, function() { 251cb0ef41Sopenharmony_ci const ecdsa = tls.connect(this.address().port, { 261cb0ef41Sopenharmony_ci ciphers: 'ECDHE-ECDSA-AES256-GCM-SHA384', 271cb0ef41Sopenharmony_ci maxVersion: 'TLSv1.2', 281cb0ef41Sopenharmony_ci rejectUnauthorized: false, 291cb0ef41Sopenharmony_ci }, common.mustCall(function() { 301cb0ef41Sopenharmony_ci ciphers.push(ecdsa.getCipher()); 311cb0ef41Sopenharmony_ci const rsa = tls.connect(server.address().port, { 321cb0ef41Sopenharmony_ci ciphers: 'ECDHE-RSA-AES256-GCM-SHA384', 331cb0ef41Sopenharmony_ci maxVersion: 'TLSv1.2', 341cb0ef41Sopenharmony_ci rejectUnauthorized: false, 351cb0ef41Sopenharmony_ci }, common.mustCall(function() { 361cb0ef41Sopenharmony_ci ciphers.push(rsa.getCipher()); 371cb0ef41Sopenharmony_ci ecdsa.end(); 381cb0ef41Sopenharmony_ci rsa.end(); 391cb0ef41Sopenharmony_ci server.close(); 401cb0ef41Sopenharmony_ci })); 411cb0ef41Sopenharmony_ci })); 421cb0ef41Sopenharmony_ci}); 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ciprocess.on('exit', function() { 451cb0ef41Sopenharmony_ci assert.deepStrictEqual(ciphers, [{ 461cb0ef41Sopenharmony_ci name: 'ECDHE-ECDSA-AES256-GCM-SHA384', 471cb0ef41Sopenharmony_ci standardName: 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384', 481cb0ef41Sopenharmony_ci version: 'TLSv1.2' 491cb0ef41Sopenharmony_ci }, { 501cb0ef41Sopenharmony_ci name: 'ECDHE-RSA-AES256-GCM-SHA384', 511cb0ef41Sopenharmony_ci standardName: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384', 521cb0ef41Sopenharmony_ci version: 'TLSv1.2' 531cb0ef41Sopenharmony_ci }]); 541cb0ef41Sopenharmony_ci}); 55