Files
node/test/parallel/test-tls-getcipher.js
2017-11-28 13:10:36 +09:00

38 lines
1.1 KiB
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const tls = require('tls');
// import fixtures directly from its module
const fixtures = require('../common/fixtures');
const cipher_list = ['AES128-SHA256', 'AES256-SHA256'];
const cipher_version_pattern = /TLS|SSL/;
const options = {
key: fixtures.readKey('agent2-key.pem'),
cert: fixtures.readKey('agent2-cert.pem'),
ciphers: cipher_list.join(':'),
honorCipherOrder: true
};
const server = tls.createServer(options,
common.mustCall(function(cleartextStream) {}));
server.listen(0, '127.0.0.1', common.mustCall(function() {
const client = tls.connect({
host: '127.0.0.1',
port: this.address().port,
ciphers: cipher_list.join(':'),
rejectUnauthorized: false
}, common.mustCall(function() {
const cipher = client.getCipher();
assert.strictEqual(cipher.name, cipher_list[0]);
assert(cipher_version_pattern.test(cipher.version));
client.end();
server.close();
}));
}));