github.com/zmap/zlint@v1.1.0/lints/lint_extra_subject_common_names.go (about) 1 /* 2 * ZLint Copyright 2019 Regents of the University of Michigan 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy 6 * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 * 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 11 * implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package lints 16 17 import ( 18 "github.com/zmap/zcrypto/x509" 19 "github.com/zmap/zlint/util" 20 ) 21 22 type extraSubjectCommonNames struct{} 23 24 func (l *extraSubjectCommonNames) Initialize() error { 25 return nil 26 } 27 28 func (l *extraSubjectCommonNames) CheckApplies(c *x509.Certificate) bool { 29 return util.IsSubscriberCert(c) 30 } 31 32 func (l *extraSubjectCommonNames) Execute(c *x509.Certificate) *LintResult { 33 // Multiple subject commonName fields are not expressly prohibited by section 34 // 7.1.4.2.2 but do seem to run afoul of the intent. For that reason we return 35 // only a Warn level finding here. 36 if len(c.Subject.CommonNames) > 1 { 37 return &LintResult{Status: Warn} 38 } 39 return &LintResult{Status: Pass} 40 } 41 42 func init() { 43 RegisterLint(&Lint{ 44 Name: "w_extra_subject_common_names", 45 Description: "if present the subject commonName field MUST contain a single IP address or Fully-Qualified Domain Name", 46 Citation: "BRs: 7.1.4.2.2", 47 Source: CABFBaselineRequirements, 48 EffectiveDate: util.CABEffectiveDate, 49 Lint: &extraSubjectCommonNames{}, 50 }) 51 }