Skip to content

Replace CertificatePinner with custom trust store using TrustManagerFactory - #112

Merged
cisco-annikiti merged 2 commits into
masterfrom
custom_trust_store
Aug 19, 2026
Merged

Replace CertificatePinner with custom trust store using TrustManagerFactory#112
cisco-annikiti merged 2 commits into
masterfrom
custom_trust_store

Conversation

@cisco-annikiti

@cisco-annikiti cisco-annikiti commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

Replace OkHttp's CertificatePinner (SPKI SHA-256 hash matching) with a custom trust store implementation using TrustManagerFactory initialized with a bundled KeyStore of root CA certificates.

Motivation and Context

CertificatePinner performs SPKI hash matching after TrustManager validation - it doesn't restrict the trust anchor set itself. The custom trust store approach restricts trust anchors at the TLS layer, provides full PKIX chain validation (signatures, expiry, chain building), and aligns with the standardized CA pinning approach across all Duo client libraries

How Has This Been Tested?

  • All existing unit tests pass (mvn test - 41 tests, 0 failures)
  • Added CertificateUtilsTest - verifies PEM loading, KeyStore creation, TrustManagerFactory initialization, and error handling
  • Updated HttpDisableCaPinningTest - verifies custom SSLSocketFactory is used by default, system trust store is used when pinning is disabled, and mutual exclusivity of options
  • Verified TLS handshake succeeds against a real Duo API host with the bundled trust store
  • Verified TLS handshake is rejected when using a trust store without the correct CAs (negative test)

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-annikiti cisco-annikiti changed the title Replace CertificatePinner with custom trust store using TrustManagerF… Replace CertificatePinner with custom trust store using TrustManagerFactory Aug 6, 2026
Comment thread duo-client/src/main/java/com/duosecurity/client/Http.java Outdated
Comment thread duo-client/src/main/java/com/duosecurity/client/Http.java Outdated
Comment thread duo-client/src/main/java/com/duosecurity/client/Http.java Outdated
@cisco-annikiti
cisco-annikiti merged commit 6a49c72 into master Aug 19, 2026
3 checks passed
@cisco-annikiti
cisco-annikiti deleted the custom_trust_store branch August 19, 2026 10:29
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.

3 participants