Skip to content

Commit dcec038

Browse files
committed
Apply skipping certification verification to authorization as well
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
1 parent be24b1a commit dcec038

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

pkg/imgutil/dockerconfigresolver/dockerconfigresolver.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ func New(refHostname string, optFuncs ...Opt) (remotes.Resolver, error) {
6262
of(&o)
6363
}
6464
var authzOpts []docker.AuthorizerOpt
65+
var insecureClient *http.Client
66+
if o.skipVerifyCerts {
67+
insecureClient = newInsecureClient()
68+
authzOpts = append(authzOpts, docker.WithAuthClient(insecureClient))
69+
}
6570
if authCreds, err := NewAuthCreds(refHostname); err != nil {
6671
return nil, err
6772
} else {
@@ -77,15 +82,7 @@ func New(refHostname string, optFuncs ...Opt) (remotes.Resolver, error) {
7782
docker.WithPlainHTTP(plainHTTPFunc),
7883
}
7984
if o.skipVerifyCerts {
80-
tr := &http.Transport{
81-
TLSClientConfig: &tls.Config{
82-
InsecureSkipVerify: true,
83-
},
84-
}
85-
client := &http.Client{
86-
Transport: tr,
87-
}
88-
regOpts = append(regOpts, docker.WithClient(client))
85+
regOpts = append(regOpts, docker.WithClient(insecureClient))
8986
}
9087
resovlerOpts := docker.ResolverOptions{
9188
Hosts: docker.ConfigureDefaultRegistries(regOpts...),
@@ -94,6 +91,17 @@ func New(refHostname string, optFuncs ...Opt) (remotes.Resolver, error) {
9491
return resolver, nil
9592
}
9693

94+
func newInsecureClient() *http.Client {
95+
tr := &http.Transport{
96+
TLSClientConfig: &tls.Config{
97+
InsecureSkipVerify: true,
98+
},
99+
}
100+
return &http.Client{
101+
Transport: tr,
102+
}
103+
}
104+
97105
// AuthCreds is for docker.WithAuthCreds
98106
type AuthCreds func(string) (string, string, error)
99107

0 commit comments

Comments
 (0)