mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
Use BoringSSL 0.20261020.0 for shared-library builds and expose the package wrapper's version to the matrix updater. The new verifier no longer emits UNABLE_TO_VERIFY_LEAF_SIGNATURE after Node's verification callback accepts a missing-issuer error. Expect UNABLE_TO_GET_ISSUER_CERT_LOCALLY for the affected leaf certificates and suggest --use-system-ca for that error. Drop the SSL_get_server_tmp_key() fallback now that BoringSSL supplies SSL_get_peer_tmp_key() as a compatibility stub. Refs: https://boringssl-review.googlesource.com/c/boringssl/+/103849 Refs: https://github.com/electron/electron/pull/55110/changes/b457e70e339e8bb3066b210edfb6f96582cdb374 Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: https://github.com/nodejs/node/pull/66922 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
'use strict';
|
|
|
|
// This tests appending certificates to existing defaults should work correctly
|
|
// with https.request().
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const https = require('https');
|
|
const tls = require('tls');
|
|
const fixtures = require('../common/fixtures');
|
|
const { includesCert, untrustedLeafErrorCode } = require('../common/tls');
|
|
|
|
const bundledCerts = tls.getCACertificates('bundled');
|
|
const fixtureCert = fixtures.readKey('fake-startcom-root-cert.pem');
|
|
if (includesCert(bundledCerts, fixtureCert)) {
|
|
common.skip('fake-startcom-root-cert is already in bundled certificates, skipping test');
|
|
}
|
|
|
|
// Test HTTPS connection fails with bundled CA, succeeds after adding custom CA
|
|
const server = https.createServer({
|
|
cert: fixtures.readKey('agent8-cert.pem'),
|
|
key: fixtures.readKey('agent8-key.pem'),
|
|
}, (req, res) => {
|
|
res.writeHead(200);
|
|
res.end('success');
|
|
});
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
|
|
// Set to bundled CA certificates - connection should fail
|
|
tls.setDefaultCACertificates(bundledCerts);
|
|
|
|
const req1 = https.request({
|
|
hostname: 'localhost',
|
|
port: port,
|
|
path: '/',
|
|
method: 'GET'
|
|
}, common.mustNotCall('Should not succeed with bundled CA only'));
|
|
|
|
req1.on('error', common.mustCall((err) => {
|
|
console.log(err);
|
|
// Should fail with certificate verification error
|
|
assert.strictEqual(err.code, untrustedLeafErrorCode);
|
|
|
|
// Now add the fake-startcom-root-cert to bundled certs - connection should succeed
|
|
tls.setDefaultCACertificates([...bundledCerts, fixtureCert]);
|
|
|
|
const req2 = https.request({
|
|
hostname: 'localhost',
|
|
port: port,
|
|
path: '/',
|
|
method: 'GET'
|
|
}, common.mustCall((res) => {
|
|
assert.strictEqual(res.statusCode, 200);
|
|
let data = '';
|
|
res.on('data', (chunk) => data += chunk);
|
|
res.on('end', common.mustCall(() => {
|
|
assert.strictEqual(data, 'success');
|
|
server.close();
|
|
}));
|
|
}));
|
|
|
|
req2.on('error', common.mustNotCall('Should not error with correct CA added'));
|
|
req2.end();
|
|
}));
|
|
|
|
req1.end();
|
|
}));
|