mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
3d2aef3979
Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. PR-URL: https://github.com/nodejs/node/pull/10698 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
37 lines
1005 B
JavaScript
37 lines
1005 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
const tls = require('tls');
|
|
|
|
const fs = require('fs');
|
|
const util = require('util');
|
|
const join = require('path').join;
|
|
|
|
const options = {
|
|
key: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent5-key.pem')),
|
|
cert: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent5-cert.pem')),
|
|
ca: [ fs.readFileSync(join(common.fixturesDir, 'keys', 'ca2-cert.pem')) ]
|
|
};
|
|
|
|
const server = tls.createServer(options, function(cleartext) {
|
|
cleartext.end('World');
|
|
});
|
|
server.listen(0, common.mustCall(function() {
|
|
const socket = tls.connect({
|
|
port: this.address().port,
|
|
rejectUnauthorized: false
|
|
}, common.mustCall(function() {
|
|
const peerCert = socket.getPeerCertificate();
|
|
|
|
console.error(util.inspect(peerCert));
|
|
assert.strictEqual(peerCert.subject.CN, 'Ádám Lippai');
|
|
server.close();
|
|
}));
|
|
socket.end('Hello');
|
|
}));
|