mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.1 KiB
55 lines
1.1 KiB
13 years ago
|
if (!process.versions.openssl) {
|
||
|
console.error('Skipping because node compiled without OpenSSL.');
|
||
|
process.exit(0);
|
||
|
}
|
||
|
|
||
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
|
var tls = require('tls');
|
||
|
var fs = require('fs');
|
||
|
var path = require('path');
|
||
|
|
||
|
var key = fs.readFileSync(path.join(common.fixturesDir, 'pass-key.pem'));
|
||
|
var cert = fs.readFileSync(path.join(common.fixturesDir, 'pass-cert.pem'));
|
||
|
|
||
|
var server = tls.Server({
|
||
|
key: key,
|
||
|
passphrase: 'passphrase',
|
||
|
cert: cert,
|
||
13 years ago
|
ca: [cert],
|
||
13 years ago
|
requestCert: true,
|
||
|
rejectUnauthorized: true
|
||
|
}, function(s) {
|
||
|
s.end();
|
||
|
});
|
||
|
|
||
|
var connectCount = 0;
|
||
|
server.listen(common.PORT, function() {
|
||
13 years ago
|
var c = tls.connect({
|
||
|
port: common.PORT,
|
||
13 years ago
|
key: key,
|
||
|
passphrase: 'passphrase',
|
||
13 years ago
|
cert: cert,
|
||
|
rejectUnauthorized: false
|
||
13 years ago
|
}, function() {
|
||
|
++connectCount;
|
||
|
});
|
||
|
c.on('end', function() {
|
||
|
server.close();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
assert.throws(function() {
|
||
13 years ago
|
tls.connect({
|
||
|
port: common.PORT,
|
||
13 years ago
|
key: key,
|
||
|
passphrase: 'invalid',
|
||
13 years ago
|
cert: cert,
|
||
|
rejectUnauthorized: false
|
||
13 years ago
|
});
|
||
|
});
|
||
|
|
||
|
process.on('exit', function() {
|
||
|
assert.equal(connectCount, 1);
|
||
|
});
|