Skip to content

Commit 8417eb1

Browse files
committed
fixup! tls: reject chains containing blocked public keys
Use only X509_STORE_CTX APIs that BoringSSL also provides. BoringSSL lacks X509_STORE_CTX_set_error_depth, X509_STORE_CTX_set_current_cert and X509_STORE_CTX_get_verify_cb, which broke the aarch64 shared BoringSSL build. Fetch the per-certificate callback from the SSL object instead and skip the two setters on BoringSSL, where Node.js' own callbacks never read them. Assisted-by: Claude Signed-off-by: Ulises Gascon <[email protected]>
1 parent 71af0a9 commit 8417eb1

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎src/crypto/crypto_context.cc‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1578,9 +1578,21 @@ int CertVerifyCallback(X509_STORE_CTX* ctx, void*) {
15781578
result == SpkiCheck::kBlocked
15791579
? X509_V_ERR_CERT_REVOKED
15801580
: X509_V_ERR_UNSPECIFIED);
1581+
#ifdef OPENSSL_IS_BORINGSSL
1582+
// BoringSSL has no setters for the error depth and current certificate.
1583+
// Node.js' own verify callbacks do not read them, so only the error is
1584+
// recorded there.
1585+
(void)depth;
1586+
(void)offender;
1587+
#else
15811588
X509_STORE_CTX_set_error_depth(ctx, depth);
15821589
X509_STORE_CTX_set_current_cert(ctx, offender);
1583-
X509_STORE_CTX_verify_cb verify_cb = X509_STORE_CTX_get_verify_cb(ctx);
1590+
#endif
1591+
// The per-certificate callback is the one carried by the SSL object; it is
1592+
// what the library installs on the store context before calling this hook.
1593+
SSL* ssl = static_cast<SSL*>(
1594+
X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()));
1595+
auto verify_cb = ssl != nullptr ? SSL_get_verify_callback(ssl) : nullptr;
15841596
if (verify_cb == nullptr) return 0;
15851597
return verify_cb(0, ctx) ? 1 : 0;
15861598
}

0 commit comments

Comments
 (0)