From b852605193fb06ad295084cc3a022024dc8de379 Mon Sep 17 00:00:00 2001 From: DQ Date: Wed, 12 Feb 2020 19:01:59 +0800 Subject: [PATCH] Feat: enable mtls in harbor replication Signed-off-by: DQ --- make/photon/prepare/utils/configs.py | 2 +- src/replication/adapter/harbor/adapter.go | 9 ++++++++- src/replication/adapter/native/adapter.go | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/make/photon/prepare/utils/configs.py b/make/photon/prepare/utils/configs.py index 1d361dca4..b6cff2bfd 100644 --- a/make/photon/prepare/utils/configs.py +++ b/make/photon/prepare/utils/configs.py @@ -347,7 +347,7 @@ def parse_yaml_config(config_file_path, with_notary, with_clair, with_trivy, wit external_database=config_dict['external_database']) if config_dict['internal_tls'].enabled: - config_dict['registry_url']: 'https://registry:5443' + config_dict['registry_url'] = 'https://registry:5443' config_dict['registry_controller_url'] = 'https://registryctl:8443' config_dict['core_url'] = 'https://core:8443' config_dict['core_local_url'] = 'https://127.0.0.1:8443' diff --git a/src/replication/adapter/harbor/adapter.go b/src/replication/adapter/harbor/adapter.go index 6e2ccfeb4..7d9b86410 100644 --- a/src/replication/adapter/harbor/adapter.go +++ b/src/replication/adapter/harbor/adapter.go @@ -26,7 +26,9 @@ import ( "github.com/goharbor/harbor/src/common/http/modifier" common_http_auth "github.com/goharbor/harbor/src/common/http/modifier/auth" "github.com/goharbor/harbor/src/common/utils/log" + "github.com/goharbor/harbor/src/jobservice/config" "github.com/goharbor/harbor/src/pkg/registry/auth/basic" + adp "github.com/goharbor/harbor/src/replication/adapter" "github.com/goharbor/harbor/src/replication/adapter/native" "github.com/goharbor/harbor/src/replication/model" @@ -68,7 +70,12 @@ type adapter struct { } func newAdapter(registry *model.Registry) (*adapter, error) { - transport := util.GetHTTPTransport(registry.Insecure) + var transport *http.Transport + if registry.URL == config.GetCoreURL() { + transport = common_http.GetHTTPTransport(common_http.InternalTransport) + } else { + transport = util.GetHTTPTransport(registry.Insecure) + } // local Harbor instance if registry.Credential != nil && registry.Credential.Type == model.CredentialTypeSecret { authorizer := common_http_auth.NewSecretAuthorizer(registry.Credential.AccessSecret) diff --git a/src/replication/adapter/native/adapter.go b/src/replication/adapter/native/adapter.go index 0537e713b..2235343a6 100644 --- a/src/replication/adapter/native/adapter.go +++ b/src/replication/adapter/native/adapter.go @@ -17,6 +17,10 @@ package native import ( "errors" "fmt" + "sync" + + "sync" + "github.com/goharbor/harbor/src/common/utils" "github.com/goharbor/harbor/src/common/utils/log" "github.com/goharbor/harbor/src/internal"