Only strip labels when both the domain and constraint have more than one
label.
Fixes #76935
Fixes #77322
Change-Id: I1144c9f03cbfc3b858af153a839b193bb934618d
Reviewed-on: https://go-review.googlesource.com/c/go/+/739420
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
},
expectedError: "\"*.example.com\" is not permitted",
},
+ // #89: a TLD constraint doesn't exclude unrelated wildcards
+ {
+ roots: []constraintsSpec{
+ {
+ bad: []string{"dns:tld"},
+ },
+ },
+ intermediates: [][]constraintsSpec{
+ {
+ {},
+ },
+ },
+ leaf: leafSpec{
+ sans: []string{"dns:*.example.com"},
+ },
+ },
}
func makeConstraintsCACert(constraints constraintsSpec, name string, key *ecdsa.PrivateKey, parent *Certificate, parentKey *ecdsa.PrivateKey) (*Certificate, error) {
return false, nil
}
- if excluded && wildcardDomain && len(domainLabels) > 1 && len(constraintLabels) > 0 {
+ if excluded && wildcardDomain && len(domainLabels) > 1 && len(constraintLabels) > 1 {
domainLabels = domainLabels[:len(domainLabels)-1]
constraintLabels = constraintLabels[:len(constraintLabels)-1]
}