Skip to content

Commit

Permalink
Fix handling of Subject:commonName not present in lint for BR 7.1.4.2…
Browse files Browse the repository at this point in the history
….2a mailbox-validated (#845)

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

* Add test case for no commonName attribute present
  • Loading branch information
robstradling authored May 24, 2024
1 parent 456dc01 commit 8523152
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
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
BgNVBAcTB1NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE+MDwGA1UE
AxM1U2VjdGlnbyBSU0EgQ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