Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Fix insecure-host-checking for repos with an explicit port #1967

Merged
merged 4 commits into from
Apr 24, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion registry/client_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package registry
import (
"context"
"crypto/tls"
"net"
"net/http"
"net/url"
"sync"
Expand Down Expand Up @@ -92,9 +93,14 @@ attemptChallenge:
}

func (f *RemoteClientFactory) ClientFor(repo image.CanonicalName, creds Credentials) (Client, error) {
repoHost, _, err := net.SplitHostPort(repo.Domain)
if err != nil {
return nil, err
}
insecure := false
for _, h := range f.InsecureHosts {
if repo.Domain == h {
if repoHost == h || repo.Domain == h {
// allow host with out without the port in the insecure hosts list
hiddeco marked this conversation as resolved.
Show resolved Hide resolved
insecure = true
break
}
Expand Down