mirror of
https://github.com/nodejs/node.git
synced 2026-10-29 02:35:20 +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>
157 lines
3.9 KiB
JavaScript
157 lines
3.9 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const { untrustedLeafErrorCode } = require('../common/tls');
|
|
|
|
const assert = require('assert');
|
|
const https = require('https');
|
|
|
|
const agent = new https.Agent();
|
|
|
|
const options = {
|
|
key: fixtures.readKey('agent1-key.pem'),
|
|
cert: fixtures.readKey('agent1-cert.pem'),
|
|
};
|
|
|
|
const expectedHeader = /^HTTP\/1\.1 200 OK/;
|
|
const expectedBody = /hello world\n/;
|
|
|
|
function checkRequest(socket, server) {
|
|
let result = '';
|
|
socket.on('connect', common.mustCall((data) => {
|
|
socket.write('GET / HTTP/1.1\r\nHost: example.com\r\n\r\n');
|
|
socket.end();
|
|
}));
|
|
socket.on('data', common.mustCall((chunk) => {
|
|
result += chunk;
|
|
}));
|
|
socket.on('end', common.mustCall(() => {
|
|
assert.match(result, expectedHeader);
|
|
assert.match(result, expectedBody);
|
|
server.close();
|
|
}));
|
|
};
|
|
|
|
function createServer() {
|
|
return https.createServer(options, (req, res) => {
|
|
res.end('hello world\n');
|
|
});
|
|
}
|
|
|
|
// use option connect
|
|
{
|
|
const server = createServer();
|
|
server.listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
const host = 'localhost';
|
|
const options = {
|
|
port: port,
|
|
host: host,
|
|
rejectUnauthorized: false,
|
|
_agentKey: agent.getName({ port, host })
|
|
};
|
|
|
|
const socket = agent.createConnection(options);
|
|
checkRequest(socket, server);
|
|
}));
|
|
}
|
|
|
|
// Use port and option connect
|
|
{
|
|
const server = createServer();
|
|
server.listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
const host = 'localhost';
|
|
const options = {
|
|
rejectUnauthorized: false,
|
|
_agentKey: agent.getName({ port, host })
|
|
};
|
|
const socket = agent.createConnection(port, options);
|
|
checkRequest(socket, server);
|
|
}));
|
|
}
|
|
|
|
// Use port and host and option connect
|
|
{
|
|
const server = createServer();
|
|
server.listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
const host = 'localhost';
|
|
const options = {
|
|
rejectUnauthorized: false,
|
|
_agentKey: agent.getName({ port, host })
|
|
};
|
|
const socket = agent.createConnection(port, host, options);
|
|
checkRequest(socket, server);
|
|
}));
|
|
}
|
|
|
|
// Use port and host and option does not have agentKey
|
|
{
|
|
const server = createServer();
|
|
server.listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
const host = 'localhost';
|
|
const options = {
|
|
rejectUnauthorized: false,
|
|
};
|
|
const socket = agent.createConnection(port, host, options);
|
|
checkRequest(socket, server);
|
|
}));
|
|
}
|
|
|
|
// `options` is null
|
|
{
|
|
const server = createServer();
|
|
server.listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
const host = 'localhost';
|
|
const options = null;
|
|
const socket = agent.createConnection(port, host, options);
|
|
socket.on('error', common.mustCall((e) => {
|
|
assert.strictEqual(e.code, untrustedLeafErrorCode);
|
|
server.close();
|
|
}));
|
|
}));
|
|
}
|
|
|
|
// `options` is undefined
|
|
{
|
|
const server = createServer();
|
|
server.listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
const host = 'localhost';
|
|
const options = undefined;
|
|
const socket = agent.createConnection(port, host, options);
|
|
socket.on('error', common.mustCall((e) => {
|
|
assert.strictEqual(e.code, untrustedLeafErrorCode);
|
|
server.close();
|
|
}));
|
|
}));
|
|
}
|
|
|
|
// `options` should not be modified
|
|
{
|
|
const server = createServer();
|
|
server.listen(0, common.mustCall(() => {
|
|
const port = server.address().port;
|
|
const host = 'localhost';
|
|
const options = common.mustNotMutateObjectDeep({
|
|
port: 3000,
|
|
rejectUnauthorized: false,
|
|
});
|
|
|
|
const socket = agent.createConnection(port, host, options);
|
|
socket.on('connect', common.mustCall((data) => {
|
|
socket.end();
|
|
}));
|
|
socket.on('end', common.mustCall(() => {
|
|
server.close();
|
|
}));
|
|
}));
|
|
}
|