Implement server certificate store

This commit is contained in:
adnano
2020-10-11 23:48:18 -04:00
parent 3b5cc23d28
commit 065ed828fb
7 changed files with 58 additions and 25 deletions

View File

@@ -218,10 +218,8 @@ func (c *Client) Send(req *Request) (*Response, error) {
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
}
if cert, err := c.CertificateStore.Lookup(req.Hostname()); err == nil {
return cert, nil
}
return &tls.Certificate{}, nil
},
@@ -280,10 +278,6 @@ func (c *Client) Send(req *Request) (*Response, error) {
if req.Certificate != nil {
return resp, nil
}
// Create the certificate store if it does not exist
if c.CertificateStore == nil {
c.CertificateStore = CertificateStore{}
}
if c.GetCertificate != nil {
if cert := c.GetCertificate(req.Hostname(), c.CertificateStore); cert != nil {
req.Certificate = cert