Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of Subject:commonName not present in lint for BR 7.1.4.2.2a mailbox-validated #845

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion v3/lints/cabf_smime_br/lint_commonname_mailbox_validated.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ func (l *commonNameMailboxValidated) CheckApplies(c *x509.Certificate) bool {
}

func (l *commonNameMailboxValidated) Execute(c *x509.Certificate) *lint.LintResult {
commonNames := []string{c.Subject.CommonName}
var commonNames []string
if c.Subject.CommonName != "" {
commonNames = append(commonNames, c.Subject.CommonName)
}
commonNames = append(commonNames, c.Subject.CommonNames...)
for _, cn := range commonNames {
if !util.IsMailboxAddress(cn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ func TestCommonNameMailboxValidated(t *testing.T) {
InputFilename string
ExpectedResult lint.LintStatus
}{
{
Name: "pass - no commonName attribute present",
InputFilename: "smime/mailbox_validated_common_name_absent.pem",
ExpectedResult: lint.Pass,
},
{
Name: "pass - valid email in commonName",
InputFilename: "smime/mailbox_validated_common_name_good_email.pem",
Expand Down
30 changes: 30 additions & 0 deletions v3/testdata/smime/mailbox_validated_common_name_absent.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-----BEGIN CERTIFICATE-----
MIIFODCCBCCgAwIBAgIRAIe9uh1DAJY6+ckykEvuYmAwDQYJKoZIhvcNAQELBQAw
gZYxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO
BgNVBAcTB1NhbGZvcmQxGD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