Fix configurations with no server provided

When a server is specified at the top level, there is a bug
that prevents the keys from being checked properly.
When no server is provided, the server attempts to parse
with an empty host, leaving partial values and a defaulted
skip verify configuration.

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan
2020-05-19 18:31:07 -07:00
parent 06b0cd45ba
commit 84619ee998
2 changed files with 27 additions and 30 deletions

View File

@@ -80,6 +80,7 @@ ca = "/etc/path/default"
[host."https://mirror.registry"]
capabilities = ["pull"]
ca = "/etc/certs/mirror.pem"
skip_verify = false
[host."https://mirror-bak.registry/us"]
capabilities = ["pull"]
@@ -132,7 +133,6 @@ ca = "/etc/path/default"
{filepath.FromSlash("/etc/certs/client.cert"), filepath.FromSlash("/etc/certs/client.key")},
{filepath.FromSlash("/etc/certs/client.pem"), ""},
},
skipVerify: &fb,
},
{
scheme: "https",
@@ -142,7 +142,6 @@ ca = "/etc/path/default"
clientPairs: [][2]string{
{filepath.FromSlash("/etc/certs/client.pem")},
},
skipVerify: &fb,
},
{
scheme: "https",
@@ -153,14 +152,13 @@ ca = "/etc/path/default"
{filepath.FromSlash("/etc/certs/client-1.pem")},
{filepath.FromSlash("/etc/certs/client-2.pem")},
},
skipVerify: &fb,
},
{
scheme: "https",
host: "test-default.registry",
path: "/v2",
capabilities: allCaps,
skipVerify: &fb,
caCerts: []string{filepath.FromSlash("/etc/path/default")},
},
}
hosts, err := parseHostsFile(ctx, "", []byte(testtoml))