mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 06:18:09 +00:00

PFX is not PEM, its binary DER. Use the same .pfx extension as test/fixtures/test_cert.pfx does. PR-URL: https://github.com/nodejs/node/pull/24374 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('node compiled without crypto.');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
// This test ensures that TLS does not fail to read a self-signed certificate
|
|
// and thus throw an `authorizationError`.
|
|
// https://github.com/nodejs/node/issues/5100
|
|
|
|
const assert = require('assert');
|
|
const tls = require('tls');
|
|
|
|
const pfx = fixtures.readKey('agent1.pfx');
|
|
|
|
const server = tls
|
|
.createServer(
|
|
{
|
|
pfx: pfx,
|
|
passphrase: 'sample',
|
|
requestCert: true,
|
|
rejectUnauthorized: false
|
|
},
|
|
common.mustCall(function(c) {
|
|
assert.strictEqual(c.getPeerCertificate().serialNumber,
|
|
'FAD50CC6A07F516C');
|
|
assert.strictEqual(c.authorizationError, null);
|
|
c.end();
|
|
})
|
|
)
|
|
.listen(0, function() {
|
|
const client = tls.connect(
|
|
{
|
|
port: this.address().port,
|
|
pfx: pfx,
|
|
passphrase: 'sample',
|
|
rejectUnauthorized: false
|
|
},
|
|
function() {
|
|
assert.strictEqual(client.getCertificate().serialNumber,
|
|
'FAD50CC6A07F516C');
|
|
client.end();
|
|
server.close();
|
|
}
|
|
);
|
|
});
|