From e6072d8bbc42d7d37b648d7ef3b1169aa13ea7eb Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Tue, 27 Oct 2020 23:47:13 -0400 Subject: [PATCH] Ensure absolute paths in client certificate store --- cert.go | 6 ++++++ examples/client.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cert.go b/cert.go index 4f11fe6..da77478 100644 --- a/cert.go +++ b/cert.go @@ -77,6 +77,12 @@ type ClientCertificateStore struct { func (c *ClientCertificateStore) Lookup(hostname, urlPath string) (*tls.Certificate, error) { urlPath = path.Clean(urlPath) + if urlPath == "." { + urlPath = "/" + } + if urlPath[0] != '/' { + urlPath = "/" + urlPath + } for { cert, err := c.CertificateStore.Lookup(hostname + urlPath) switch err { diff --git a/examples/client.go b/examples/client.go index 852b126..169f726 100644 --- a/examples/client.go +++ b/examples/client.go @@ -77,8 +77,8 @@ func sendRequest(req *gemini.Request) error { } if resp.Status.Class() == gemini.StatusClassSuccess { - defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) + resp.Body.Close() if err != nil { return err }