Pin on certificate SPKI across the full chain, with CustomRootTrust on .NET 5+ - #48
Open
cisco-dmytro-hissa wants to merge 4 commits into
Open
Pin on certificate SPKI across the full chain, with CustomRootTrust on .NET 5+#48cisco-dmytro-hissa wants to merge 4 commits into
cisco-dmytro-hissa wants to merge 4 commits into
Conversation
cisco-dmytro-hissa
marked this pull request as ready for review
August 11, 2026 16:21
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.
Description
Reworks CA pinning to match the certificate chains that Windows and Linux actually build (ZTCAPIN-558).
SubjectPublicKeyInfo, so the self-signed and cross-signed forms of the same CA both match. Replaces the old root-onlyContains()DER comparison, which rejected valid cross-signed chains.SpkiPinning.cs— hand-rolled DER walk to extract the SPKI, becausePublicKey.ExportSubjectPublicKeyInfo()is .NET 6+ only and we still ship net48.CustomTrustStore(TrustMode = CustomRootTrust), so a pinned certificate must be able to anchor the chain, not merely appear in it. Consequence: pinning an intermediate viaGetCustomRootCertificatesPinneris accepted on net48 and rejected on net8.0. Documented on that method; the bundledca_certs.pemis roots-only, so it behaves identically on both.-----BEGIN/END CERTIFICATE-----+ base64) rather than relying on framework-specific behavior of theX509Certificate(byte[])constructor.NullReferenceExceptioninHasProxyServeron .NET Core/5+. It reflected over .NET Framework's privatewebProxyfield and dereferenced the null result; now falls back toIWebProxy.IsBypassed/GetProxy. This was 17 test failures on net8.0.net48;net8.0,packages.configremoved, CI switched todotnet restore/build/test.How Has This Been Tested?
TestComputeSpkiSha256MatchesOpenSsl— SPKI hashes checked againstopenssl-computed values for the Duo root, intermediate, and a Microsoft root.TestAllBundledCertsHashable— every cert inca_certs.pemparses through the DER walk;TestEmptyDataThrowscovers malformed input.TestPinnedRootAcceptedOnAllFrameworks/TestPinnedIntermediateIsAcceptedOnlyWhereItCanAnchor— pin the anchor contract per TFM.TestUnrelatedPinnedKeyRejected,TestChainErrorRejected,TestSpkiHashIsDeterministic.TestServerbinding to a hardcoded port 8080.dotnet testruns the net48 and net8.0 hosts concurrently, so the second one died withHttpListenerException (183). It now takes an OS-assigned ephemeral port, and listener/write errors no longer take down the test host.Types of Changes