github.com/zmap/zlint@v1.1.0/lints/lint_qcstatem_qccompliance_valid.go (about) 1 /* 2 * ZLint Copyright 2017 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 "encoding/asn1" 19 "github.com/zmap/zcrypto/x509" 20 "github.com/zmap/zlint/util" 21 ) 22 23 type qcStatemQcComplianceValid struct{} 24 25 func (this *qcStatemQcComplianceValid) getStatementOid() *asn1.ObjectIdentifier { 26 return &util.IdEtsiQcsQcCompliance 27 } 28 29 func (l *qcStatemQcComplianceValid) Initialize() error { 30 return nil 31 } 32 33 func (l *qcStatemQcComplianceValid) CheckApplies(c *x509.Certificate) bool { 34 if !util.IsExtInCert(c, util.QcStateOid) { 35 return false 36 } 37 if util.ParseQcStatem(util.GetExtFromCert(c, util.QcStateOid).Value, *l.getStatementOid()).IsPresent() { 38 return true 39 } 40 return false 41 } 42 43 func (l *qcStatemQcComplianceValid) Execute(c *x509.Certificate) *LintResult { 44 45 errString := "" 46 ext := util.GetExtFromCert(c, util.QcStateOid) 47 s := util.ParseQcStatem(ext.Value, *l.getStatementOid()) 48 errString += s.GetErrorInfo() 49 if len(errString) == 0 { 50 return &LintResult{Status: Pass} 51 } else { 52 return &LintResult{Status: Error, Details: errString} 53 } 54 } 55 56 func init() { 57 RegisterLint(&Lint{ 58 Name: "e_qcstatem_qccompliance_valid", 59 Description: "Checks that a QC Statement of the type id-etsi-qcs-QcCompliance has the correct form", 60 Citation: "ETSI EN 319 412 - 5 V2.2.1 (2017 - 11) / Section 4.2.1", 61 Source: EtsiEsi, 62 EffectiveDate: util.EtsiEn319_412_5_V2_2_1_Date, 63 Lint: &qcStatemQcComplianceValid{}, 64 }) 65 }