| 1 |
package rfc |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
import ( |
| 18 |
"github.com/zmap/zcrypto/x509" |
| 19 |
"github.com/zmap/zlint/v3/lint" |
| 20 |
"github.com/zmap/zlint/v3/util" |
| 21 |
) |
| 22 |
|
| 23 |
type SANDNSTooLong struct{} |
| 24 |
|
| 25 |
func init() { |
| 26 |
lint.RegisterCertificateLint(&lint.CertificateLint{ |
| 27 |
LintMetadata: lint.LintMetadata{ |
| 28 |
Name: "e_ext_san_dns_name_too_long", |
| 29 |
Description: "DNSName must be less than or equal to 253 bytes", |
| 30 |
Citation: "RFC 5280", |
| 31 |
Source: lint.RFC5280, |
| 32 |
EffectiveDate: util.RFC5280Date, |
| 33 |
}, |
| 34 |
Lint: NewSANDNSTooLong, |
| 35 |
}) |
| 36 |
} |
| 37 |
|
| 38 |
func NewSANDNSTooLong() lint.LintInterface { |
| 39 |
return &SANDNSTooLong{} |
| 40 |
} |
| 41 |
|
| 42 |
func (l *SANDNSTooLong) CheckApplies(c *x509.Certificate) bool { |
| 43 |
return util.IsExtInCert(c, util.SubjectAlternateNameOID) && len(c.DNSNames) > 0 |
| 44 |
} |
| 45 |
|
| 46 |
func (l *SANDNSTooLong) Execute(c *x509.Certificate) *lint.LintResult { |
| 47 |
for _, dns := range c.DNSNames { |
| 48 |
if len(dns) > 253 { |
| 49 |
return &lint.LintResult{Status: lint.Error} |
| 50 |
} |
| 51 |
} |
| 52 |
return &lint.LintResult{Status: lint.Pass} |
| 53 |
} |