Skip to content

Commit

Permalink
Make --insecure-registry work with TLS registries whose certs we can'…
Browse files Browse the repository at this point in the history
…t verify. (ko-build#398)

* Make --insecure-registry work with TLS registries whose certs we can't verify.

* Don't error if we can't disable TLS checking when insecure.
  • Loading branch information
evankanderson authored Jul 28, 2021
1 parent 1809666 commit f04730d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/publish/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package publish

import (
"crypto/tls"
"log"
"net/http"
"path"
Expand Down Expand Up @@ -105,6 +106,17 @@ func WithTagOnly(tagOnly bool) Option {
func Insecure(b bool) Option {
return func(i *defaultOpener) error {
i.insecure = b
t, ok := i.t.(*http.Transport)
if !ok {
return nil
}
t = t.Clone()
if t.TLSClientConfig == nil {
t.TLSClientConfig = &tls.Config{} //nolint: gosec
}
t.TLSClientConfig.InsecureSkipVerify = b //nolint: gosec
i.t = t

return nil
}
}

0 comments on commit f04730d

Please sign in to comment.