pull/32679/merge
Cosmin 4 days ago committed by GitHub
commit 57de53ac39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -53,6 +53,12 @@ func ClientConfig(opts Options) (cfg *tls.Config, err error) {
} }
} }
cfg = &tls.Config{InsecureSkipVerify: opts.InsecureSkipVerify, Certificates: []tls.Certificate{*cert}, RootCAs: pool} cfg = &tls.Config{
InsecureSkipVerify: opts.InsecureSkipVerify,
RootCAs: pool,
}
if cert != nil {
cfg.Certificates = []tls.Certificate{*cert}
}
return cfg, nil return cfg, nil
} }

@ -112,3 +112,22 @@ func TestNewClientTLS(t *testing.T) {
t.Fatalf("mismatch tls RootCAs, expecting nil") t.Fatalf("mismatch tls RootCAs, expecting nil")
} }
} }
func TestClientConfigWithoutClientCert(t *testing.T) {
opts := Options{
InsecureSkipVerify: true,
}
cfg, err := ClientConfig(opts)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if cfg == nil {
t.Fatal("expected non-nil tls.Config")
}
if len(cfg.Certificates) != 0 {
t.Fatalf("expected empty Certificates slice, got %d", len(cfg.Certificates))
}
}

Loading…
Cancel
Save