Add optional issuerKey to Cache.RemoveManaged

This commit is contained in:
Matthew Holt 2024-04-23 10:47:06 -06:00
parent 855d4670a4
commit 81683c8d20
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5

View File

@ -395,8 +395,9 @@ func (certCache *Cache) AllMatchingCertificates(name string) []Certificate {
}
// RemoveManaged removes managed certificates for the given subjects from the cache.
// This effectively stops maintenance of those certificates.
func (certCache *Cache) RemoveManaged(subjects []string) {
// This effectively stops maintenance of those certificates. Optionally pass an issuer
// key to remove only certs managed with a certain issuer.
func (certCache *Cache) RemoveManaged(subjects []string, issuerKey string) {
deleteQueue := make([]string, 0, len(subjects))
for _, subject := range subjects {
certs := certCache.getAllMatchingCerts(subject) // does NOT expand wildcards; exact matches only
@ -404,7 +405,9 @@ func (certCache *Cache) RemoveManaged(subjects []string) {
if !cert.managed {
continue
}
deleteQueue = append(deleteQueue, cert.hash)
if issuerKey == "" || cert.issuerKey == issuerKey {
deleteQueue = append(deleteQueue, cert.hash)
}
}
}
certCache.Remove(deleteQueue)