Skip to content

Commit

Permalink
httpcaddyfile: Avoid repeated subjects in APs (fix #3618)
Browse files Browse the repository at this point in the history
When consolidating automation policies, ensure same subject names do not
get appended to list.
  • Loading branch information
mholt committed Aug 6, 2020
1 parent 584eba9 commit ff19bdd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion caddyconfig/httpcaddyfile/tlsapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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--
Expand Down

0 comments on commit ff19bdd

Please sign in to comment.