Skip to content
Merged
Changes from 2 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
48 changes: 48 additions & 0 deletions linter/lints/cpcps/lint_cert_has_san_count_out_of_bounds.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package cpcps

import (
"github.com/zmap/zcrypto/x509"
"github.com/zmap/zlint/v3/lint"
"github.com/zmap/zlint/v3/util"

"github.com/letsencrypt/boulder/linter/lints"
)

type certSubjectAltNamesCountOutOfBounds struct{}

func init() {
lint.RegisterCertificateLint(&lint.CertificateLint{
LintMetadata: lint.LintMetadata{
Name: "e_cert_has_san_count_out_of_bounds",
Description: "Let's Encrypt Subscriber Certificaes must have a count of subjectAlternateNames within specific bounds defined by our CPS",
Citation: "CPS: 7.1",
Source: lints.LetsEncryptCPS,
EffectiveDate: lints.CPSV33Date, // TODO: probably earlier?
},
Lint: CertNamesCountOutOfBounds,
})
}

func CertNamesCountOutOfBounds() lint.CertificateLintInterface {
return &certSubjectAltNamesCountOutOfBounds{}
}

func (l *certSubjectAltNamesCountOutOfBounds) CheckApplies(c *x509.Certificate) bool {
return util.IsExtInCert(c, util.SubjectAlternateNameOID) && (len(c.DNSNames) > 0 || len(c.IPAddresses) > 0)
Comment thread
ezekiel marked this conversation as resolved.
Outdated
}

func (l *certSubjectAltNamesCountOutOfBounds) Execute(c *x509.Certificate) *lint.LintResult {
/*
* CP/CPS 7.1: "A sequence of 1 to 100 dNSNames or ipAddresses (critical if no CN)"
*
* more likely to encounter certs with greater than 100 than with fewer than 1
* so testing that failure first
*/
Comment thread
ezekiel marked this conversation as resolved.
Outdated
totalSANs := len(c.DNSNames) + len(c.IPAddresses)

if totalSANs > 100 || totalSANs < 1 {
return &lint.LintResult{Status: lint.Error}
}

return &lint.LintResult{Status: lint.Pass}
}
Loading