aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradnano <[email protected]>2020-09-28 00:03:42 -0400
committeradnano <[email protected]>2020-09-28 00:03:42 -0400
commit13d2bd5fea03eacb2debe9b8b1aa8b80e04d6881 (patch)
treef795a069ad22eceb0feec12b838b5b58f51053e6
parentOnly generate certificates after CertificateRequired (diff)
downloadgo-gemini-13d2bd5fea03eacb2debe9b8b1aa8b80e04d6881.tar.xz
go-gemini-13d2bd5fea03eacb2debe9b8b1aa8b80e04d6881.zip
Return certificate if it exists in the store
-rw-r--r--client.go7
1 files changed, 7 insertions, 0 deletions
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