[~] fix issue #693: fix duplicate condition in cert verify callback#805
Open
Yanmei-Liu wants to merge 1 commit into
Open
[~] fix issue #693: fix duplicate condition in cert verify callback#805Yanmei-Liu wants to merge 1 commit into
Yanmei-Liu wants to merge 1 commit into
Conversation
…lback The certificate verification callback xqc_ssl_cert_verify_cb had a copy-paste error where X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY (error 20) was checked twice. The second condition should have been X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT (error 2). This caused connections to fail when the issuer certificate was missing from the chain (error 2), because the application-layer cert_verify_cb was never invoked for that error class. Fix: - Replace the duplicate check with X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT - Extract error tolerability logic into xqc_cert_verify_err_tolerable() for testability and clarity - Add unit tests covering all branches: error 2/20 tolerated, self-signed allowed/rejected with flag, expired/revoked rejected Fixes alibaba#693
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
Fix a copy-paste bug in
xqc_ssl_cert_verify_cbwhereX509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY(error 20) was checked twice, whileX509_V_ERR_UNABLE_TO_GET_ISSUER_CERT(error 2) was never checked.These are two semantically different X509 verification errors:
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY): issuer certificate could not be found in the local trust storeX509_V_ERR_UNABLE_TO_GET_ISSUER_CERT): issuer of a looked-up certificate could not be found (chain broken at non-leaf)The duplicate condition meant that when error 2 occurred, the application-layer
cert_verify_cbwas never invoked -- connections were rejected without giving the application a chance to handle the error (e.g., for certificate pinning scenarios).Changes
src/tls/xqc_tls.c: Extract error tolerability logic intoxqc_cert_verify_err_tolerable(), fix the duplicate conditionsrc/tls/xqc_tls.h: Declare the new helper functiontests/unittest/xqc_tls_test.c: Add unit tests covering all branches of the error filtering logicTest plan
xqc_cert_verify_err_tolerable()added:cert_verifyandcrypto_error_cert_verifyintegration tests incase_test.shcover end-to-end pathsFixes #693