Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mTLS towards container registry #3922

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

zpon
Copy link

@zpon zpon commented Nov 4, 2024

Summary

Some container registries require that the client present a certificate when establishing the connection. There is currently no way of specifying this when using cosign.
This change adds four arguments that allows the users to specify the root CA, the client cert and the client key and the expected SAN name.

Release Note

  • Config changes (additions, deletions, updates)
    • None
  • API additions—new endpoint, new response fields, or newly accepted request parameters
    • None
  • Database changes (any)
    • None
  • Websocket additions or changes
    • None
  • Anything noteworthy to an administrator running private sigstore instances (err on the side of over-communicating)
    • It is now possible to specify client certificates (mTLS) for container registry connections
  • New features and improvements, including behavioural changes, UI changes and CLI changes
    • It is now possible to specify client certificates (mTLS) for container registry connections
  • Bug fixes and fixes of previous known issues
    • None
  • Deprecation warnings, breaking changes, or compatibility notes
    • None

Documentation

Documentation has been added for these new arguments added:

      --registry-cacert string                                                                   path to the X.509 CA certificate file in PEM format to be used for the connection to the registry
      --registry-client-cert string                                                              path to the X.509 certificate file in PEM format to be used for the connection to the registry
      --registry-client-key string                                                               path to the X.509 private key file in PEM format to be used, together with the 'registry-client-cert' value, for the connection to the registry
      --registry-server-name string                                                              SAN name to use as the 'ServerName' tls.Config field to verify the mTLS connection to the registry

Closes #3915

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 60.86957% with 18 lines in your changes missing coverage. Please review.

Project coverage is 36.35%. Comparing base (2ef6022) to head (4d12839).
Report is 235 commits behind head on main.

Files with missing lines Patch % Lines
cmd/cosign/cli/options/registry.go 60.86% 17 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3922      +/-   ##
==========================================
- Coverage   40.10%   36.35%   -3.75%     
==========================================
  Files         155      209      +54     
  Lines       10044    13379    +3335     
==========================================
+ Hits         4028     4864     +836     
- Misses       5530     7889    +2359     
- Partials      486      626     +140     

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

This commit refactors the registry options handling in the
`cmd/cosign/cli/options/registry.go` file. It introduces new flags for
specifying the X.509 CA certificate, client certificate, client key, and
server name for the connection to the registry.
This allows cosign to connect to registries that requires mTLS for
authentication.

Signed-off-by: Søren Juul <[email protected]>
Signed-off-by: Søren Juul <[email protected]>
Increase test coverage of `getTLSConfig` method.

Signed-off-by: Søren Juul <[email protected]>
Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

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.

Support client certificates when communicating with the registry server (mTLS)
2 participants