2 var common = require('../common');
3 var assert = require('assert');
5 if (!common.hasCrypto) {
6 console.log('1..0 # Skipped: missing crypto');
9 var tls = require('tls');
11 var fs = require('fs');
13 var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
14 var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
16 tls.createServer({ key: key, cert: cert }, function(conn) {
19 }).listen(common.PORT, function() {
20 var options = { port: this.address().port, rejectUnauthorized: true };
21 tls.connect(options).on('error', common.mustCall(function(err) {
22 assert.equal(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
23 assert.equal(err.message, 'unable to verify the first certificate');