• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3if (!common.hasCrypto)
4  common.skip('missing crypto');
5
6const assert = require('assert');
7const tls = require('tls');
8const fixtures = require('../common/fixtures');
9
10const options = {
11  pfx: [
12    {
13      buf: fixtures.readKey('agent1.pfx'),
14      passphrase: 'sample'
15    },
16    fixtures.readKey('ec.pfx'),
17  ]
18};
19
20const ciphers = [];
21
22const server = tls.createServer(options, function(conn) {
23  conn.end('ok');
24}).listen(0, function() {
25  const ecdsa = tls.connect(this.address().port, {
26    ciphers: 'ECDHE-ECDSA-AES256-GCM-SHA384',
27    maxVersion: 'TLSv1.2',
28    rejectUnauthorized: false,
29  }, common.mustCall(function() {
30    ciphers.push(ecdsa.getCipher());
31    const rsa = tls.connect(server.address().port, {
32      ciphers: 'ECDHE-RSA-AES256-GCM-SHA384',
33      maxVersion: 'TLSv1.2',
34      rejectUnauthorized: false,
35    }, common.mustCall(function() {
36      ciphers.push(rsa.getCipher());
37      ecdsa.end();
38      rsa.end();
39      server.close();
40    }));
41  }));
42});
43
44process.on('exit', function() {
45  assert.deepStrictEqual(ciphers, [{
46    name: 'ECDHE-ECDSA-AES256-GCM-SHA384',
47    standardName: 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384',
48    version: 'TLSv1.2'
49  }, {
50    name: 'ECDHE-RSA-AES256-GCM-SHA384',
51    standardName: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384',
52    version: 'TLSv1.2'
53  }]);
54});
55