diff --git a/v3/lints/cabf_smime_br/lint_commonname_mailbox_validated.go b/v3/lints/cabf_smime_br/lint_commonname_mailbox_validated.go index 06df676fd..d622f7466 100644 --- a/v3/lints/cabf_smime_br/lint_commonname_mailbox_validated.go +++ b/v3/lints/cabf_smime_br/lint_commonname_mailbox_validated.go @@ -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) { diff --git a/v3/lints/cabf_smime_br/lint_commonname_mailbox_validated_test.go b/v3/lints/cabf_smime_br/lint_commonname_mailbox_validated_test.go index 77fa56221..727d9774b 100644 --- a/v3/lints/cabf_smime_br/lint_commonname_mailbox_validated_test.go +++ b/v3/lints/cabf_smime_br/lint_commonname_mailbox_validated_test.go @@ -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", diff --git a/v3/testdata/smime/mailbox_validated_common_name_absent.pem b/v3/testdata/smime/mailbox_validated_common_name_absent.pem new file mode 100644 index 000000000..de5970a6d --- /dev/null +++ b/v3/testdata/smime/mailbox_validated_common_name_absent.pem @@ -0,0 +1,30 @@ +-----BEGIN CERTIFICATE----- +MIIFODCCBCCgAwIBAgIRAIe9uh1DAJY6+ckykEvuYmAwDQYJKoZIhvcNAQELBQAw +gZYxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO +BgNVBAcTB1NhbGZvcmQxGDAWB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