A DNS name prefixed with an empty label should be considered invalid
when checking constraints (i.e. ".example.com" does not satisfy a
constraint of "example.com").
Updates #65085
Change-Id: I42919dc06abedc0e242ff36b2a42b583b14857b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/561615
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
cn: "foo.bar",
},
},
+
+ // #85: .example.com is an invalid DNS name, it should not match the
+ // constraint example.com.
+ {
+ roots: []constraintsSpec{{ok: []string{"dns:example.com"}}},
+ leaf: leafSpec{sans: []string{"dns:.example.com"}},
+ expectedError: "cannot parse dnsName \".example.com\"",
+ },
}
func makeConstraintsCACert(constraints constraintsSpec, name string, key *ecdsa.PrivateKey, parent *Certificate, parentKey *ecdsa.PrivateKey) (*Certificate, error) {
} else {
reverseLabels = append(reverseLabels, domain[i+1:])
domain = domain[:i]
+ if i == 0 { // domain == ""
+ // domain is prefixed with an empty label, append an empty
+ // string to reverseLabels to indicate this.
+ reverseLabels = append(reverseLabels, "")
+ }
}
}