Make tls verification optional

This commit is contained in:
Stefan Majer 2017-02-13 10:32:36 +01:00
parent b427cc03ae
commit 89031c4ab0
2 changed files with 10 additions and 3 deletions

View file

@ -46,7 +46,7 @@ func preload(c *cli.Context) (err error) {
} }
// create the registry client // create the registry client
r, err = registry.New(auth, c.GlobalBool("debug")) r, err = registry.New(auth, c.GlobalBool("debug"), c.GlobalBool("skipverify"))
if err != nil { if err != nil {
return err return err
} }
@ -69,6 +69,10 @@ func main() {
Name: "debug, d", Name: "debug, d",
Usage: "run in debug mode", Usage: "run in debug mode",
}, },
cli.BoolFlag{
Name: "skipverify, k",
Usage: "do not verify tls certificates",
},
cli.StringFlag{ cli.StringFlag{
Name: "username, u", Name: "username, u",
Usage: "username for the registry", Usage: "username for the registry",

View file

@ -33,8 +33,11 @@ func Log(format string, args ...interface{}) {
} }
// New creates a new Registry struct with the given URL and credentials. // New creates a new Registry struct with the given URL and credentials.
func New(auth types.AuthConfig, debug bool) (*Registry, error) { func New(auth types.AuthConfig, debug bool, skipverify bool) (*Registry, error) {
transport := http.DefaultTransport transport := http.DefaultTransport.(*http.Transport)
transport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: skipverify,
}
return newFromTransport(auth, transport, debug) return newFromTransport(auth, transport, debug)
} }