Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions deps/ncrypto/ncrypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4998,11 +4998,7 @@ bool SSLPointer::isServer() const {
EVPKeyPointer SSLPointer::getPeerTempKey() const {
if (!ssl_) return {};
EVP_PKEY* raw_key = nullptr;
#ifndef OPENSSL_IS_BORINGSSL
if (!SSL_get_peer_tmp_key(get(), &raw_key)) return {};
#else
if (!SSL_get_server_tmp_key(get(), &raw_key)) return {};
#endif
return EVPKeyPointer(raw_key);
}

Expand Down
3 changes: 3 additions & 0 deletions src/crypto/crypto_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ MaybeLocal<Value> GetValidationErrorReason(Environment* env, int err) {
// Suggest --use-system-ca if the error indicates a certificate issue
bool suggest_system_ca =
(err == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE) ||
#ifdef OPENSSL_IS_BORINGSSL
(err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) ||
#endif
(err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) ||
((err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT) &&
!env->options()->use_system_ca);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if (!common.hasCrypto)
// https must be dynamically imported so that builds without crypto support
// can skip it.
const { default: https } = await import('node:https');
const { untrustedLeafErrorCodePattern } = await import('../common/tls.js');

const server = https.createServer({
cert: fixtures.readKey('agent8-cert.pem'),
Expand All @@ -36,8 +37,10 @@ const { code, signal, stderr, stdout } = await runProxiedRequest({
HTTPS_PROXY: `http://localhost:${proxy.address().port}`,
});

// The proxy client should get a UNABLE_TO_VERIFY_LEAF_SIGNATURE during TLS handshake.
assert.match(stderr, /UNABLE_TO_VERIFY_LEAF_SIGNATURE/);
// The proxy client should report the untrusted leaf during the TLS handshake.
const errorCode = stderr.match(/code: '([^']+)'/);
assert(errorCode, stderr);
assert.match(errorCode[1], untrustedLeafErrorCodePattern);
assert.strictEqual(stdout, '');
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
Expand Down
28 changes: 0 additions & 28 deletions test/common/boringssl.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,33 +167,6 @@ function testEphemeralKeyInfo() {
}));
}

/**
* The protocol matrix tests cover OpenSSL behavior for legacy TLS protocols.
* For BoringSSL we only need to exhibit that a TLSv1-only client cannot connect
* to a server whose minimum protocol is TLS 1.2; the client receives the
* protocol-version alert instead of the OpenSSL version-specific matrix.
*/
function testLegacyProtocolUnsupported() {
const server = tls.createServer({
key: fixtures.readKey('agent2-key.pem'),
cert: fixtures.readKey('agent2-cert.pem'),
minVersion: 'TLSv1.2',
}, common.mustNotCall());

server.on('tlsClientError', common.mustCall());
server.listen(0, common.mustCall(() => {
const client = tls.connect({
port: server.address().port,
rejectUnauthorized: false,
secureProtocol: 'TLSv1_method',
}, common.mustNotCall());
client.on('error', common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION');
server.close();
}));
}));
}

/**
* BoringSSL can load a multi-PFX option well enough to serve the ECDSA
* identity, but it does not provide the same OpenSSL multi-identity selection
Expand Down Expand Up @@ -335,7 +308,6 @@ module.exports = {
assertNoCipherMatch,
assertOpenSSLSecurityLevelsUnsupported,
testEphemeralKeyInfo,
testLegacyProtocolUnsupported,
testMultiPfxSelectionDifference,
testPskTls13Unsupported,
testRenegotiationUnsupported,
Expand Down
8 changes: 8 additions & 0 deletions test/common/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
const crypto = require('crypto');
const net = require('net');
const assert = require('assert');
const { isBoringSSL } = require('./crypto');

// Newer BoringSSL reports the missing issuer directly for a lone,
// non-self-signed leaf. Older BoringSSL and OpenSSL replace it with a leaf
// signature verification error.
exports.untrustedLeafErrorCodePattern = isBoringSSL ?
/^UNABLE_TO_(?:VERIFY_LEAF_SIGNATURE|GET_ISSUER_CERT_LOCALLY)$/ :
/^UNABLE_TO_VERIFY_LEAF_SIGNATURE$/;

exports.ccs = Buffer.from('140303000101', 'hex');

Expand Down
2 changes: 1 addition & 1 deletion test/internet/test-tls-add-ca-cert.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ tls.connect(opts, common.mustCall(end));
// The .ca option replaces the well-known roots, so connection fails.
opts.ca = caCert;
tls.connect(opts, fail).on('error', common.mustCall((err) => {
assert.strictEqual(err.message, 'unable to get local issuer certificate');
assert.strictEqual(err.code, 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY');
}));

function fail() {
Expand Down
Loading
Loading