From ff19bddac5ebfb68c77d9e2fb677b87d5c6a6524 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 6 Aug 2020 13:56:23 -0600 Subject: httpcaddyfile: Avoid repeated subjects in APs (fix #3618) When consolidating automation policies, ensure same subject names do not get appended to list. --- caddyconfig/httpcaddyfile/tlsapp.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'caddyconfig/httpcaddyfile') diff --git a/caddyconfig/httpcaddyfile/tlsapp.go b/caddyconfig/httpcaddyfile/tlsapp.go index aa3e5be..db6bf98 100644 --- a/caddyconfig/httpcaddyfile/tlsapp.go +++ b/caddyconfig/httpcaddyfile/tlsapp.go @@ -444,7 +444,12 @@ func consolidateAutomationPolicies(aps []*caddytls.AutomationPolicy) []*caddytls } else if len(aps[i].Subjects) > 0 && len(aps[j].Subjects) == 0 { aps = append(aps[:i], aps[i+1:]...) } else { - aps[i].Subjects = append(aps[i].Subjects, aps[j].Subjects...) + // avoid repeated subjects + for _, subj := range aps[j].Subjects { + if !sliceContains(aps[i].Subjects, subj) { + aps[i].Subjects = append(aps[i].Subjects, subj) + } + } aps = append(aps[:j], aps[j+1:]...) } i-- -- cgit v1.2.3