mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
PFX is not PEM, its binary DER. Use the same .pfx extension as test/fixtures/test_cert.pfx does. Backport-PR-URL: https://github.com/nodejs/node/pull/25501 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>
43 lines
989 B
JavaScript
43 lines
989 B
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.authorizationError, null);
|
|
c.end();
|
|
})
|
|
)
|
|
.listen(0, function() {
|
|
const client = tls.connect(
|
|
{
|
|
port: this.address().port,
|
|
pfx: pfx,
|
|
passphrase: 'sample',
|
|
rejectUnauthorized: false
|
|
},
|
|
function() {
|
|
client.end();
|
|
server.close();
|
|
}
|
|
);
|
|
});
|