Add flag to trust ssl certificates signed by unknown authority (#16)

This commit is contained in:
Stefan Majer 2017-03-31 11:11:18 +02:00 committed by Jess Frazelle
parent e8a0e8958a
commit d91bf05217
2 changed files with 16 additions and 3 deletions

View file

@ -29,6 +29,7 @@ GLOBAL OPTIONS:
--username value, -u value username for the registry
--password value, -p value password for the registry
--registry value, -r value URL to the private registry (ex. r.j3ss.co)
--insecure, -k do not verify tls certificates of registry
--port value port for server to run on (default: "8080")
--cert value path to ssl cert
--key value path to ssl key

View file

@ -32,6 +32,7 @@ var (
updating = false
wg sync.WaitGroup
tmpl *template.Template
r *registry.Registry
)
// preload initializes any global options and configuration
@ -69,6 +70,10 @@ func main() {
Name: "registry, r",
Usage: "URL to the private registry (ex. r.j3ss.co)",
},
cli.BoolFlag{
Name: "insecure, k",
Usage: "do not verify tls certificates of registry",
},
cli.StringFlag{
Name: "port",
Value: "8080",
@ -99,9 +104,16 @@ func main() {
}
// create the registry client
r, err := registry.New(auth, c.GlobalBool("debug"))
if err != nil {
logrus.Fatal(err)
if c.GlobalBool("insecure") {
r, err = registry.NewInsecure(auth, c.GlobalBool("debug"))
if err != nil {
logrus.Fatal(err)
}
} else {
r, err = registry.New(auth, c.GlobalBool("debug"))
if err != nil {
logrus.Fatal(err)
}
}
// get the path to the static directory