Remove excessive copyright/license boilerplate
[platform/upstream/nodejs.git] / test / parallel / test-tls-friendly-error-message.js
1 if (!process.versions.openssl) {
2   console.error('Skipping because node compiled without OpenSSL.');
3   process.exit(0);
4 }
5
6 var common = require('../common');
7 var assert = require('assert');
8 var fs = require('fs');
9 var tls = require('tls');
10
11 var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
12 var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
13
14 tls.createServer({ key: key, cert: cert }, function(conn) {
15   conn.end();
16   this.close();
17 }).listen(common.PORT, function() {
18   var options = { port: this.address().port, rejectUnauthorized: true };
19   tls.connect(options).on('error', common.mustCall(function(err) {
20     assert.equal(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
21     assert.equal(err.message, 'unable to verify the first certificate');
22     this.destroy();
23   }));
24 });