Move certificate verification code to VerifyConnection

This commit is contained in:
adnano
2020-10-13 16:44:46 -04:00
parent db89a34935
commit 3d1e9e5519
7 changed files with 18 additions and 60 deletions
+2 -2
View File
@@ -41,11 +41,11 @@ func (c *CertificateStore) Add(hostname string, cert tls.Certificate) {
func (c *CertificateStore) Lookup(hostname string) (*tls.Certificate, error) {
cert, ok := c.store[hostname]
if !ok {
return nil, ErrUnknownCertificate
return nil, ErrCertificateUnknown
}
// Ensure that the certificate is not expired
if cert.Leaf != nil && cert.Leaf.NotAfter.Before(time.Now()) {
return &cert, ErrInvalidCertificate
return &cert, ErrCertificateExpired
}
return &cert, nil
}