From 13d2bd5fea03eacb2debe9b8b1aa8b80e04d6881 Mon Sep 17 00:00:00 2001 From: adnano Date: Mon, 28 Sep 2020 00:03:42 -0400 Subject: [PATCH] Return certificate if it exists in the store --- client.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client.go b/client.go index 94b4363..0f799c0 100644 --- a/client.go +++ b/client.go @@ -208,6 +208,12 @@ func (c *Client) Send(req *Request) (*Response, error) { if req.Certificate != nil { return req.Certificate, nil } + // If we have already stored the certificate, return it + if c.CertificateStore != nil { + if cert, ok := c.CertificateStore[req.Hostname()]; ok { + return cert, nil + } + } return &tls.Certificate{}, nil }, VerifyPeerCertificate: func(rawCerts [][]byte, _ [][]*x509.Certificate) error { @@ -261,6 +267,7 @@ func (c *Client) Send(req *Request) (*Response, error) { // Resend the request with a certificate if the server responded // with CertificateRequired if resp.Status == StatusCertificateRequired { + log.Print("Client certificate required") // Check to see if a certificate was already provided to prevent an infinite loop if req.Certificate != nil { return resp, nil