Skip to content

Support configuring custom CA certificates#687

Merged
jonesbusy merged 1 commit into
oras-project:mainfrom
ThomasVitale:gh-670
Apr 18, 2026
Merged

Support configuring custom CA certificates#687
jonesbusy merged 1 commit into
oras-project:mainfrom
ThomasVitale:gh-670

Conversation

@ThomasVitale
Copy link
Copy Markdown
Contributor

@ThomasVitale ThomasVitale commented Apr 18, 2026

Description

  • Introduce .withCaFile() and .withCaContent() method to Registry and HttpClient to provide custom CA certificates to be used for establishing a TLS connection with an OCI registry.
  • Refactor HttpClient.Builder to ensure correct and consistent state when using multiple TLS-related methods like .withSkipTlsVerify(), .withCaFile(), and .withCaContent().
  • Add integration tests for TLS-related operations with a Zot OCI registry. Introduce a ZotBaseContainer class to consolidate common logic rather than duplicating code in the newly added ZotTlsContainer for TLS-related tests.

Fixes gh-670

Testing done

  • Added unit tests covering the new feature.
  • Added integration tests covering the new feature.

Submitter checklist

  • I have read and understood the CONTRIBUTING guide
  • I have run mvn license:update-file-header, mvn spotless:apply, pre-commit run -a, mvn clean install before opening the PR

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2026

Codecov Report

❌ Patch coverage is 95.77465% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.62%. Comparing base (f230da5) to head (01d8caf).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/main/java/land/oras/auth/HttpClient.java 96.55% 2 Missing ⚠️
src/main/java/land/oras/Registry.java 92.30% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #687      +/-   ##
============================================
+ Coverage     86.70%   87.62%   +0.92%     
- Complexity      943      962      +19     
============================================
  Files            43       43              
  Lines          2910     2974      +64     
  Branches        364      371       +7     
============================================
+ Hits           2523     2606      +83     
+ Misses          229      210      -19     
  Partials        158      158              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jonesbusy jonesbusy added the enhancement New feature or request label Apr 18, 2026
@jonesbusy
Copy link
Copy Markdown
Collaborator

Thanks for your PR. Looks very good so far.

I've added copilot review so see if it spots anything

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for configuring custom CA certificates for TLS connections to OCI registries, and introduces test infrastructure + integration tests to validate TLS behaviors against a Zot registry.

Changes:

  • Add withCaFile() / withCaContent() to HttpClient.Builder and Registry.Builder, and refactor TLS configuration to be applied consistently at build time.
  • Introduce shared Zot Testcontainers utilities (ZotBaseContainer, TestImages) and a TLS-enabled Zot container (ZotTlsContainer).
  • Add unit tests for TLS configuration validation and integration tests covering CA file/content and skip-verify behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/java/land/oras/auth/HttpClient.java Implements CA file/content handling and refactors TLS configuration logic in the client builder.
src/main/java/land/oras/Registry.java Plumbs CA configuration through Registry.Builder into the internal HttpClient.
src/test/java/land/oras/auth/HttpClientTest.java Adds unit tests for CA file/content validation and option incompatibilities.
src/test/java/land/oras/RegistryTlsTest.java Adds integration coverage for connecting to a TLS-enabled Zot registry using CA file/content and skip-verify.
src/test/java/land/oras/utils/ZotBaseContainer.java New shared base for Zot containers (image/port/config copy helpers, logging, registry address).
src/test/java/land/oras/utils/ZotContainer.java Refactors existing auth-enabled Zot container to use ZotBaseContainer.
src/test/java/land/oras/utils/ZotUnsecureContainer.java Refactors unsecure Zot container to use ZotBaseContainer and shared config-writing.
src/test/java/land/oras/utils/ZotTlsContainer.java New TLS-enabled Zot container that generates/copies certs and exposes CA to tests.
src/test/java/land/oras/utils/TlsUtils.java New test utility for generating certificates/keys (BouncyCastle-backed).
src/test/java/land/oras/utils/TestImages.java Centralizes container image references used in tests.
pom.xml Adds test dependency on bcpkix-jdk18on (and manages its version).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/land/oras/auth/HttpClient.java
Comment thread src/main/java/land/oras/auth/HttpClient.java
@ThomasVitale ThomasVitale force-pushed the gh-670 branch 2 times, most recently from b88f914 to e6bd886 Compare April 18, 2026 14:10
@ThomasVitale
Copy link
Copy Markdown
Contributor Author

I've just noticed the zot.yaml file that needs updating after the refactoring of the Zot container test classes. I'm fixing it now.

- Introduce .withCaFile() and .withCaContent() method to Registry and HttpClient to provide custom CA certificates to be used for establishing a TLS connection with an OCI registry.
- Refactor HttpClient.Builder to ensure correct and consistent state when using multiple TLS-related methods like .withSkipTlsVerify, .withCaFile(), and .withCaContent().
- Add integration tests for TLS-related operations with a Zot OCI registry. Introduce a ZotBaseContainer class to consolidate common logic rather than duplicating code in the newly added ZotTlsContainer for TLS-related tests.

Fixes oras-projectgh-670

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
@ThomasVitale
Copy link
Copy Markdown
Contributor Author

Updated zot.yaml now.

@jonesbusy jonesbusy merged commit ecda376 into oras-project:main Apr 18, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support configuring custom CA certificate

4 participants