revise installing a license file
[platform/upstream/nodejs.git] / test / parallel / test-tls-friendly-error-message.js
1 'use strict';
2 var common = require('../common');
3 var assert = require('assert');
4
5 if (!common.hasCrypto) {
6   console.log('1..0 # Skipped: missing crypto');
7   return;
8 }
9 var tls = require('tls');
10
11 var fs = require('fs');
12
13 var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
14 var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
15
16 tls.createServer({ key: key, cert: cert }, function(conn) {
17   conn.end();
18   this.close();
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');
24     this.destroy();
25   }));
26 });