Return certificate if it exists in the store
This commit is contained in:
parent
5d099a4fe1
commit
13d2bd5fea
|
@ -208,6 +208,12 @@ func (c *Client) Send(req *Request) (*Response, error) {
|
||||||
if req.Certificate != nil {
|
if req.Certificate != nil {
|
||||||
return 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
|
return &tls.Certificate{}, nil
|
||||||
},
|
},
|
||||||
VerifyPeerCertificate: func(rawCerts [][]byte, _ [][]*x509.Certificate) error {
|
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
|
// Resend the request with a certificate if the server responded
|
||||||
// with CertificateRequired
|
// with CertificateRequired
|
||||||
if resp.Status == StatusCertificateRequired {
|
if resp.Status == StatusCertificateRequired {
|
||||||
|
log.Print("Client certificate required")
|
||||||
// Check to see if a certificate was already provided to prevent an infinite loop
|
// Check to see if a certificate was already provided to prevent an infinite loop
|
||||||
if req.Certificate != nil {
|
if req.Certificate != nil {
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user