Conversation
mimicAuthorityKeyId() returned early whenever mimicCert was absent, and its only caller sat inside the "if (properties.mimicCert.get())" branch of buildCertificate(). In client-first bump Squid completes the client handshake before contacting the origin, so properties.mimicCert is null and generated certificates carried no Authority Key Identifier at all. RFC 5280 section 4.2.1.1 requires the keyIdentifier field in certificates generated by a conforming CA (except for self-signed certificates), and that exception does not apply because the signing CA has a Subject Key Identifier. Strict validators therefore reject the forged leaves: Python 3.13+ with VERIFY_X509_STRICT fails the handshake, and openssl verify -x509_strict reports "error 85 at 0 depth lookup: Missing Authority Key Identifier". The origin certificate is not needed to build the extension. The value of the keyIdentifier field is taken from issuerCert; mimicCert only decided the shape (whether to write keyIdentifier, and whether to also write authorityCertIssuer plus authorityCertSerialNumber). This change: * Renames mimicAuthorityKeyId() to addAuthorityKeyId() to reflect that the extension presence (not its value) is what gets mimicked; the value is always built from the signing CA. * Moves the "!addKeyId && !addIssuer" check to the top level of the function so that it covers all current and future paths. * Calls mimicExtensions() unconditionally from buildCertificate() and makes mimicExtensions() tolerate a nil mimicCert, instead of adding a second, conditional call site. * Fixes the mimicExtensions() description comment. The mimicking path behavior is unchanged: with mimicCert present the same fields are read from the origin certificate, the same early return applies, and the value-construction section is untouched.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
yadij
requested changes
Sep 24, 2026
rousskov
self-requested a review
September 24, 2026 12:48
Contributor
|
@ccijunk, thank you for sharing this fix! Please add yourself to the P.S. No need to squash or rebase your PR branch as you add commits. PR commits will be squashed automatically when merging your PR. |
Fold nid into the for-loop parameters instead of declaring it in an enclosing scope, and use auto for the newly declared ext variable, as requested in PR review.
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
Certificates generated by SslBump in client-first mode carried
no Authority Key Identifier (AKI) extension:
mimicAuthorityKeyId()returned early whenevermimicCertwas absent, andif (properties.mimicCert.get())branch ofbuildCertificate().In client-first bump Squid completes the client handshake
before contacting the origin, so
properties.mimicCertisnull and the generated leaf had no AKI at all. Strict X.509
validators therefore reject every forged leaf on every bumped
connection, even though the chain is otherwise fully trusted:
VERIFY_X509_STRICT(the default forconda 26+) fails the TLS handshake with
Missing Authority Key Identifier;openssl verify -x509_strictreportserror 85 at 0 depth lookup: Missing Authority Key Identifier.The failure is mode-dependent and therefore unintended: the
same proxy, signing CA and client produce a valid certificate
in server-first mode and an invalid one in client-first mode.
The origin certificate is not needed to build the extension.
The value of the
keyIdentifierfield is taken fromissuerCert;mimicCertonly decided the shape (whetherto write
keyIdentifier, and whether to also writeauthorityCertIssuerplusauthorityCertSerialNumber).Per RFC 5280 section 4.2.1.1, the keyIdentifier field is
required in certificates generated by a conforming CA
(except for self-signed certificates), and that exception
does not apply because the signing CA has a Subject Key
Identifier.
Changes
mimicAuthorityKeyId()toaddAuthorityKeyId():Squid mimics the extension presence, but the extension
value is always built from the signing CA rather than
copied, so the old name was misleading.
!addKeyId && !addIssuercheck to the top levelof the function so it covers all current and future paths.
mimicExtensions()unconditionally frombuildCertificate()and makemimicExtensions()toleratea nil
mimicCert, instead of adding a second, conditionalcall site.
mimicExtensions()description comment (itsaid extensions were copied "from cert to
mimicCert" - backwards).
The mimicking path behavior is unchanged: with
mimicCertpresent the same fields are read from the origin
certificate, the same early return applies, and the
value-construction section is untouched.
Testing
With a client-first bump configuration (
ssl_bump bump step1):openssl x509 -texton the captured leaf showsAuthority Key Identifier: keyid:<signing CA's SKI>,matching the Subject Key Identifier of the CA certificate
openssl verify -x509_strict -CAfile squid-ca.pem leaf.pemreturns OKVERIFY_X509_STRICTcompletes the TLS handshake through the proxy
untouched)
Note: the AKI is the only extension that needs to be added -
the generated leaf still lacks key usage, extended key usage,
basic constraints and a Subject Key Identifier, and strict
validation does not object to any of those.