-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(docker): add support for mTLS authentication when connecting to registry #4649
Conversation
Manveer Singh seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
… - added error handling
pkg/remote/remote.go
Outdated
return nil, err | ||
} | ||
tr.TLSClientConfig = &tls.Config{ | ||
RootCAs: caCertPool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If RootCAs is nil, TLS uses the host's root CA set.
https://pkg.go.dev/crypto/tls#Config
Do we need to set it manually?
pkg/remote/remote.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
tr.TLSClientConfig = &tls.Config{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, it overwrites InsecureSkipVerify
by mistake and leads to a bug.
pkg/remote/remote.go
Outdated
@@ -124,6 +134,23 @@ func httpTransport(insecure bool) *http.Transport { | |||
return tr | |||
} | |||
|
|||
func httpTransportWithMtls(insecure bool, clientCert []byte, clientKey []byte) (*http.Transport, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to merge this functionality into httpTransport
.
tlsConfig := &tls.Config{InsecureSkipVerify: insecure}
if len(option.ClientCert) > 0 && len(option.ClientKey) > 0 {
cert, err := tls.X509KeyPair(option.ClientCert, option.ClientKey)
if err != nil {
return nil, err
}
tlsConfig.Certificates = []tls.Certificate{cert}
}
tr.TLSClientConfig = tlsConfig
- code quality improvements
And need to resolve the conflict |
…registry (aquasecurity#4649) * feat: add support for mTLS authentication when connecting to registry * feat: add support for mTLS authentication when connecting to registry - added error handling * feat: add support for mTLS authentication when connecting to registry - code quality improvements * feat: add support for mTLS authentication when connecting to registry - code quality improvements * wrap errors --------- Co-authored-by: knqyf263 <knqyf263@gmail.com>
Description
Added two new fields in registry options ClientCert and ClientKey. If both of these are not empty then https connection with client certificates will be attempted to the registry.
Related issues
Checklist