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

Questions around secure/insecure registry connection #720

Closed
chanseokoh opened this issue Jul 26, 2018 · 3 comments
Closed

Questions around secure/insecure registry connection #720

chanseokoh opened this issue Jul 26, 2018 · 3 comments
Assignees
Labels

Comments

@chanseokoh
Copy link
Member

chanseokoh commented Jul 26, 2018

First Question

To create a RegistryAuthenticator instance, one should use RegistryAuthenticator.Initializer.initialize(). It may return null if the registry uses insecure HTTPS or plain HTTP.

    public RegistryAuthenticator initialize() throws ..., RegistryException {
      ...
      } catch (InsecureRegistryException ex) {
        // Cannot skip certificate validation or use HTTP, so just return null.
        return null;
      }

There are two places where a RegistryAuthenticator instance is created: AuthenticatePushStep.call() and PullBaseImageStep.call(). And they handle null (insecure HTTPS or plain HTTP) differently.

PullBaseImageStep:

          RegistryAuthenticator registryAuthenticator =
              RegistryAuthenticator.initializer(...) ... .initialize();
          if (registryAuthenticator == null) {
            ... .error(
                    "Failed to retrieve authentication challenge for registry that required token authentication");
            throw registryUnauthorizedException;
          }
          registryCredentials =
              registryAuthenticator.setAuthorization(registryCredentials).authenticatePull();

AuthenticatePushStep:

      RegistryAuthenticator registryAuthenticator =
          RegistryAuthenticator.initializer(...) ... .initialize();
      if (registryAuthenticator == null) {
        return registryCredentials;
      }
      return registryAuthenticator.setAuthorization(registryCredentials).authenticatePush();

Why? I'm trying to understand the difference of the steps for the logic.

Second Question

The core functionality of RegistryAuthenticator is the eventual method authenticate() which contacts the URL <realm>?service=<service>&scope=repository:<repository>:<scope>. I'm thinking <realm> would probably contain a protocol (e.g., https://), but I'm not so sure. Anyways, currently authenticate() is not being affected by allowInsecureRegistries, as it doesn't use RegistryEndpointCaller to make a call which handles allowInsecureRegistries. Instead, it establishes a Connection on its own.

      try (Connection connection = Connection.getConnectionFactory().apply(authenticationUrl)) {
        Request.Builder requestBuilder =
            Request.builder().setHttpTimeout(Integer.getInteger("jib.httpTimeout"));
        if (authorization != null) {
          requestBuilder.setAuthorization(authorization);
        }

Hence it isn't affected by the current HTTP-failover when allowInsecureRegistries is set. Is RegistryAuthenticator supposed to be affected? This, I'm not so sure.

@chanseokoh
Copy link
Member Author

chanseokoh commented Aug 3, 2018

Alright, I think we do have a real issue with RegistryAuthenticator, which is another place that makes a Connection independent of RegistryEndpointCaller: #746 (comment)

Obviously, RegistryAuthenticator does not care about allowInsecureRegistries.

@chanseokoh
Copy link
Member Author

chanseokoh commented Aug 3, 2018

Alright, I think we do have a real issue with RegistryAuthenticator, which is another place that makes a Connection independent of RegistryEndpointCaller: #746 (comment)

Obviously, RegistryAuthenticator does not care about allowInsecureRegistries.

But at the same time, I think it would be pretty rare that an auth server is insecure. #746 (comment) may be a very special case where SSL validation fails unpredictably possibly due to some issue in the customer's local environment.

So, now I think we don't really need to try to apply allowInsecureRegistries to RegistryAuthenticator at least for now. If we find actual use-cases, we can consider it then.

@chanseokoh
Copy link
Member Author

Had a discussion about the first question offline, and they are working as intended.

Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant