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

@@ -58,7 +58,7 @@ func init() {
}
DefaultClient.GetCertificate = func(hostname string, store CertificateStore) *tls.Certificate {
// If the certificate is in the store, return it
if cert, ok := store[hostname]; ok {
if cert, err := store.Lookup(hostname); err == nil {
return cert
}
// Otherwise, generate a certificate
@@ -68,7 +68,7 @@ func init() {
return nil
}
// Store and return the certificate
store[hostname] = &cert
store.Add(hostname, cert)
return &cert
}
}