Skip to content

Commit

Permalink
Fix 1.8 regression preventing email addresses being used as common na…
Browse files Browse the repository at this point in the history
…me within pki certs (#12336)
  • Loading branch information
stevendpclark committed Oct 4, 2021
1 parent 77e8f0f commit 2c0fb7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion builtin/logical/pki/cert_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ func validateNames(b *backend, data *inputBundle, names []string) string {
// is enabled
if data.role.AllowBareDomains &&
(strings.EqualFold(sanitizedName, currDomain) ||
(isEmail && strings.EqualFold(emailDomain, currDomain))) {
(isEmail && strings.EqualFold(emailDomain, currDomain)) ||
// Handle the use case of AllowedDomain being an email address
(isEmail && strings.EqualFold(name, currDomain))) {
valid = true
break
}
Expand Down
17 changes: 17 additions & 0 deletions builtin/logical/pki/cert_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,23 @@ func TestPki_PermitFQDNs(t *testing.T) {
},
expected: []string{"Example.Net", "eXaMPLe.COM"},
},
"case email as AllowedDomain with bare domains": {
input: &inputBundle{
apiData: &framework.FieldData{
Schema: fields,
Raw: map[string]interface{}{
"common_name": "test@testemail.com",
"ttl": 3600,
},
},
role: &roleEntry{
AllowedDomains: []string{"test@testemail.com"},
AllowBareDomains: true,
MaxTTL: 3600,
},
},
expected: []string{},
},
}

for _, testCase := range cases {
Expand Down

0 comments on commit 2c0fb7a

Please sign in to comment.