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