Add an option to disable CA pinning#45
Open
cisco-dmytro-hissa wants to merge 1 commit into
Open
Conversation
cisco-dmytro-hissa
marked this pull request as ready for review
July 21, 2026 14:37
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
Duo.cs— Added new public constructor overloadDuoApi(ikey, skey, host, user_agent, bool disableCaPinning). Existing 3- and 4-arg constructors flow through withdisableCaPinning: false, so default behavior isunchanged.
Duo.cs— Added acaPinningEnabledfield (default true) and threadeddisableCaPinningthrough the protected constructor as an optional parameter, keeping theTestDuoApisubclass source-compatible.Duo.cs— InGetCertificatePinner(), when pinning is disabled (and SSL validation isn't fully off / no custom roots set), returns the OS-trust-store validator instead of the Duo pinner.Duo.cs—UseCustomRootCertificates()now throwsInvalidOperationExceptionwhen CA pinning is disabled, since custom roots are themselves a form of pinning and the two are contradictory. Updated the XML doc tonote the incompatibility.
CertificatePinnerFactory.cs— AddedGetOsTrustStoreValidator(), which accepts a connection only when the platform's default chain validation passes (sslPolicyErrors == SslPolicyErrors.None) — unlikeGetCertificateDisabler(), which disables TLS entirely.How Has This Been Tested?
OsTrustStoreValidatorTest.TestSuccess— Valid Duo chain is accepted.OsTrustStoreValidatorTest.TestUnpinnedRootAccepted— A valid non-Duo root (which the Duo pinner would reject) is accepted — the key behavioral difference from pinning.OsTrustStoreValidatorTest.TestFatalSslError— Name-mismatch SSL policy error is rejected (TLS still enforced).OsTrustStoreValidatorTest.TestChainErrorRejected— Chain-error SSL policy error is rejected.OsTrustStoreValidatorTest.TestNoCertificateRejected— Missing certificate is rejected.DisableCaPinningConfigTest.TestCustomRootsWithPinningDisabledThrows—UseCustomRootCertificates()throwsInvalidOperationExceptionwhen pinning is disabled.DisableCaPinningConfigTest.TestCustomRootsWithPinningEnabledSucceeds—UseCustomRootCertificates()succeeds and returns the client for chaining when pinning is enabled.Types of Changes