From 17561c1c0c464ba9dca2687c43da49d9bf44890d Mon Sep 17 00:00:00 2001 From: cmeng Date: Mon, 22 Apr 2024 09:00:48 +1200 Subject: [PATCH] fix(docker-client): explicitly set docker client scheme EE-6935 (#11519) --- api/docker/client/client.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/docker/client/client.go b/api/docker/client/client.go index 66b1255b7..71a9ae233 100644 --- a/api/docker/client/client.go +++ b/api/docker/client/client.go @@ -93,11 +93,17 @@ func createTCPClient(endpoint *portainer.Endpoint, timeout *time.Duration) (*cli return nil, err } - return client.NewClientWithOpts( + opts := []client.Opt{ client.WithHost(endpoint.URL), client.WithAPIVersionNegotiation(), client.WithHTTPClient(httpCli), - ) + } + + if nnTransport, ok := httpCli.Transport.(*NodeNameTransport); ok && nnTransport.TLSClientConfig != nil { + opts = append(opts, client.WithScheme("https")) + } + + return client.NewClientWithOpts(opts...) } func createAgentClient(endpoint *portainer.Endpoint, endpointURL string, signatureService portainer.DigitalSignatureService, nodeName string, timeout *time.Duration) (*client.Client, error) {