Skip to content

Add an option to disable CA pinning#45

Open
cisco-dmytro-hissa wants to merge 1 commit into
masterfrom
disable-ca-pinning
Open

Add an option to disable CA pinning#45
cisco-dmytro-hissa wants to merge 1 commit into
masterfrom
disable-ca-pinning

Conversation

@cisco-dmytro-hissa

Copy link
Copy Markdown

Description

  • Duo.cs — Added new public constructor overload DuoApi(ikey, skey, host, user_agent, bool disableCaPinning). Existing 3- and 4-arg constructors flow through with disableCaPinning: false, so default behavior is
    unchanged.
  • Duo.cs — Added a caPinningEnabled field (default true) and threaded disableCaPinning through the protected constructor as an optional parameter, keeping the TestDuoApi subclass source-compatible.
  • Duo.cs — In GetCertificatePinner(), 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.csUseCustomRootCertificates() now throws InvalidOperationException when CA pinning is disabled, since custom roots are themselves a form of pinning and the two are contradictory. Updated the XML doc to
    note the incompatibility.
  • CertificatePinnerFactory.cs — Added GetOsTrustStoreValidator(), which accepts a connection only when the platform's default chain validation passes (sslPolicyErrors == SslPolicyErrors.None) — unlike
    GetCertificateDisabler(), 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.TestCustomRootsWithPinningDisabledThrowsUseCustomRootCertificates() throws InvalidOperationException when pinning is disabled.
  • DisableCaPinningConfigTest.TestCustomRootsWithPinningEnabledSucceedsUseCustomRootCertificates() succeeds and returns the client for chaining when pinning is enabled.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@cisco-dmytro-hissa
cisco-dmytro-hissa marked this pull request as ready for review July 21, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant