• 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    rejectUnauthorized: false
28  }, common.mustCall(function() {
29    ciphers.push(ecdsa.getCipher());
30    const rsa = tls.connect(server.address().port, {
31      ciphers: 'ECDHE-RSA-AES256-GCM-SHA384',
32      rejectUnauthorized: false
33    }, common.mustCall(function() {
34      ciphers.push(rsa.getCipher());
35      ecdsa.end();
36      rsa.end();
37      server.close();
38    }));
39  }));
40});
41
42process.on('exit', function() {
43  assert.deepStrictEqual(ciphers, [{
44    name: 'ECDHE-ECDSA-AES256-GCM-SHA384',
45    standardName: 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384',
46    version: 'TLSv1.2'
47  }, {
48    name: 'ECDHE-RSA-AES256-GCM-SHA384',
49    standardName: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384',
50    version: 'TLSv1.2'
51  }]);
52});
53