fix(ext/node): fix TLS client certificate authentication verification#33576
Open
bartlomieju wants to merge 1 commit intomainfrom
Open
fix(ext/node): fix TLS client certificate authentication verification#33576bartlomieju wants to merge 1 commit intomainfrom
bartlomieju wants to merge 1 commit intomainfrom
Conversation
Fixes several issues in the node:tls client certificate authentication flow so that `test-tls-client-auth.js` passes: - Normalize `BEGIN TRUSTED CERTIFICATE` and `BEGIN X509 CERTIFICATE` PEM headers to `BEGIN CERTIFICATE` before passing to rustls_pemfile, matching OpenSSL behavior. - Replace blanket acceptance of X.509v1 certs (UnsupportedCertVersion) with structural chain verification via issuer/subject DER matching, so v1 certs with valid chains succeed while broken chains produce the correct Node/OpenSSL error codes. - Make NodeClientCertVerifier store errors and always succeed the TLS handshake, letting the JS layer (onServerSocketSecure) handle client cert rejection. This produces ECONNRESET on the client instead of a TLS fatal alert, matching Node.js behavior. - Add CertificateRequired alert mapping with TLS-version awareness (TLS 1.2 maps to SSLV3_ALERT_HANDSHAKE_FAILURE to match OpenSSL). - Fix UNABLE_TO_GET_ISSUER_CERT_LOCALLY vs UNABLE_TO_VERIFY_LEAF_SIGNATURE distinction based on whether explicit CAs were provided.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes several issues in the
node:tlsclient certificate authentication flow:BEGIN TRUSTED CERTIFICATEandBEGIN X509 CERTIFICATEheaders are now normalized toBEGIN CERTIFICATEbefore parsing (both client and server configs), matching OpenSSL behaviorNodeClientCertVerifier::verify_client_certnow always succeeds the TLS handshake, storing errors for the JS layer (onServerSocketSecure) to handle rejection viathis.destroy(), producingECONNRESETon the client instead of a TLS fatal alert, matching Node.js behaviorCertificateRequiredalert mapping with version-aware logic (TLS 1.2 maps toSSLV3_ALERT_HANDSHAKE_FAILUREto match OpenSSL)UNABLE_TO_GET_ISSUER_CERT_LOCALLYvsUNABLE_TO_VERIFY_LEAF_SIGNATUREdistinction based on whether explicit CAs were providedTest plan
./x test-compat test-tls-client-auth.jspasses (was failing)./x test-compat test-tls-client-- same pass/fail set as before (no regressions), plustest-tls-client-auth.jsnow passing./tools/lint.jspasses./tools/format.jspasses