2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-01 10:54:34 -06:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
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:54:34 -06:00
|
|
|
const tls = require('tls');
|
2014-01-17 18:15:36 +01:00
|
|
|
|
2016-12-01 10:54:34 -06:00
|
|
|
const fs = require('fs');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
2016-12-01 10:54:34 -06:00
|
|
|
const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
|
|
|
|
const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
|
2014-01-17 18:15:36 +01:00
|
|
|
|
2016-12-01 10:54:34 -06:00
|
|
|
tls.createServer({ key: key, cert: cert }, common.mustCall(function(conn) {
|
2014-01-17 18:15:36 +01:00
|
|
|
conn.end();
|
|
|
|
this.close();
|
2016-12-01 10:54:34 -06:00
|
|
|
})).listen(0, common.mustCall(function() {
|
2017-01-08 13:19:00 +00:00
|
|
|
const options = { port: this.address().port, rejectUnauthorized: true };
|
2014-01-17 18:15:36 +01:00
|
|
|
tls.connect(options).on('error', common.mustCall(function(err) {
|
2016-12-01 10:54:34 -06:00
|
|
|
assert.strictEqual(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
|
|
|
|
assert.strictEqual(err.message, 'unable to verify the first certificate');
|
2014-01-17 18:15:36 +01:00
|
|
|
this.destroy();
|
|
|
|
}));
|
2016-12-01 10:54:34 -06:00
|
|
|
}));
|