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 for Sinker accessing registries over TLS #67

Open
mh013370 opened this issue Jun 23, 2022 · 1 comment
Open

Support for Sinker accessing registries over TLS #67

mh013370 opened this issue Jun 23, 2022 · 1 comment

Comments

@mh013370
Copy link

mh013370 commented Jun 23, 2022

The docker client will configure its HTTP client transport to use TLS if you configure it properly through environment variables:

However, sinker doesn't use the docker client for every registry interaction. When it doesn't, it uses the go container registry client with basic auth.

For example: https://github.com/plexsystems/sinker/blob/v0.17.0/internal/docker/docker.go#L178

Due to this, for container registries that are TLS enabled and where basic auth isn't possible, sinker won't completely work.

I think there may be a fix, though. The docker client exposes its TLS-configured HTTPClient.Transport, which can be provided to the go-containerregistry remote client. For example:

func (c Client) ImageExistsAtRemote(ctx context.Context, image string) (bool, error) {
// ... 
  if _,  err := remote.Get(reference, 
    remote.WithTransport(c.docker.HTTPClient().Transport), 
    remote.WithAuthFromKeychain(authn.DefaultKeychain)); err != nil {
    // do something
  }
}

This way, if the environment is configured correctly then the docker client will load client certs which can be used in comms in sinker.

It's completely possible i'm approaching this incorrectly. If this is possible without code changes, please enlighten me 😄

I'm also happy to raise a PR. If my proposed solution seems reasonable, I'll raise one.

@mh013370
Copy link
Author

The other alternative is to just use the docker client for all registry interactions, but that may not be advised if the goal is to support all OCI images.

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

No branches or pull requests

1 participant