Skip to content

Commit 140a6fa

Browse files
committed
Improve API from previous commit to pair Subject with Issuer
1 parent 81683c8 commit 140a6fa

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

cache.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -394,18 +394,24 @@ func (certCache *Cache) AllMatchingCertificates(name string) []Certificate {
394394
return certs
395395
}
396396

397+
// SubjectIssuer pairs a subject name with an issuer ID/key.
398+
type SubjectIssuer struct {
399+
Subject, IssuerKey string
400+
}
401+
397402
// RemoveManaged removes managed certificates for the given subjects from the cache.
398-
// This effectively stops maintenance of those certificates. Optionally pass an issuer
399-
// key to remove only certs managed with a certain issuer.
400-
func (certCache *Cache) RemoveManaged(subjects []string, issuerKey string) {
403+
// This effectively stops maintenance of those certificates. If an IssuerKey is
404+
// specified alongside the subject, only certificates for that subject from the
405+
// specified issuer will be removed.
406+
func (certCache *Cache) RemoveManaged(subjects []SubjectIssuer) {
401407
deleteQueue := make([]string, 0, len(subjects))
402-
for _, subject := range subjects {
403-
certs := certCache.getAllMatchingCerts(subject) // does NOT expand wildcards; exact matches only
408+
for _, subj := range subjects {
409+
certs := certCache.getAllMatchingCerts(subj.Subject) // does NOT expand wildcards; exact matches only
404410
for _, cert := range certs {
405411
if !cert.managed {
406412
continue
407413
}
408-
if issuerKey == "" || cert.issuerKey == issuerKey {
414+
if subj.IssuerKey == "" || cert.issuerKey == subj.IssuerKey {
409415
deleteQueue = append(deleteQueue, cert.hash)
410416
}
411417
}

0 commit comments

Comments
 (0)