2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-01 10:29:05 -06:00
|
|
|
const common = require('../common');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
2016-05-11 15:34:52 -04:00
|
|
|
common.skip('missing crypto');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2015-03-04 12:11:21 +11:00
|
|
|
}
|
2016-12-01 10:29:05 -06:00
|
|
|
const assert = require('assert');
|
|
|
|
const tls = require('tls');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
2016-12-01 10:29:05 -06:00
|
|
|
const fs = require('fs');
|
|
|
|
const cipher_list = ['AES128-SHA256', 'AES256-SHA256'];
|
|
|
|
const cipher_version_pattern = /TLS|SSL/;
|
|
|
|
const options = {
|
2012-03-23 15:10:48 +09:00
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'),
|
|
|
|
ciphers: cipher_list.join(':'),
|
|
|
|
honorCipherOrder: true
|
|
|
|
};
|
|
|
|
|
2016-12-01 10:29:05 -06:00
|
|
|
const server = tls.createServer(options,
|
|
|
|
common.mustCall(function(cleartextStream) {}));
|
2012-03-23 15:10:48 +09:00
|
|
|
|
2016-12-01 10:29:05 -06:00
|
|
|
server.listen(0, '127.0.0.1', common.mustCall(function() {
|
|
|
|
const client = tls.connect({
|
2012-08-30 16:43:20 +02:00
|
|
|
host: '127.0.0.1',
|
2016-05-29 03:06:56 -04:00
|
|
|
port: this.address().port,
|
2015-02-15 18:35:14 +01:00
|
|
|
ciphers: cipher_list.join(':'),
|
2012-08-30 16:43:20 +02:00
|
|
|
rejectUnauthorized: false
|
2016-12-01 10:29:05 -06:00
|
|
|
}, common.mustCall(function() {
|
|
|
|
const cipher = client.getCipher();
|
|
|
|
assert.strictEqual(cipher.name, cipher_list[0]);
|
2012-03-23 15:10:48 +09:00
|
|
|
assert(cipher_version_pattern.test(cipher.version));
|
|
|
|
client.end();
|
|
|
|
server.close();
|
2016-12-01 10:29:05 -06:00
|
|
|
}));
|
|
|
|
}));
|