From 6f1d8df9b1bede85b91e5c6ecaa07c2873f00102 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Sun, 13 Mar 2022 12:05:14 -0500 Subject: [PATCH] Handle unset cert and key Signed-off-by: Levi Harrison Signed-off-by: Simon Pasquier --- config/http_config.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/config/http_config.go b/config/http_config.go index 8beb9f0d..d8d47229 100644 --- a/config/http_config.go +++ b/config/http_config.go @@ -902,11 +902,14 @@ func (t *tlsRoundTripper) getTLSFilesWithHash() ([]byte, []byte, []byte, []byte, } h1 := sha256.Sum256(b1) - b2, b3, err := readCertAndKey(t.certFile, t.keyFile) - if err != nil { - return nil, nil, nil, nil, err + var h2, h3 [32]byte + if t.certFile != "" { + b2, b3, err := readCertAndKey(t.certFile, t.keyFile) + if err != nil { + return nil, nil, nil, nil, err + } + h2, h3 = sha256.Sum256(b2), sha256.Sum256(b3) } - h2, h3 := sha256.Sum256(b2), sha256.Sum256(b3) return b1, h1[:], h2[:], h3[:], nil }