forked from zmap/zlint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Subject Key Identifier is not recommended by CABF BR v2
With SC62, the CABF BR now lists SKI as not recommended. Per discussion in zmap#762, zlint should provide two lints, one for rfc5280 behavior and one for CABF BR. Both lint will conflict with each other, users are expected to select (or ignore) which behavior they mean to follow. Fixes zmap#749
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
v3/lints/cabf_br/lint_ext_subject_key_identifier_not_recommended_subscriber.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package cabf_br | ||
|
||
/* | ||
* ZLint Copyright 2024 Regents of the University of Michigan | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
import ( | ||
"github.com/zmap/zcrypto/x509" | ||
"github.com/zmap/zlint/v3/lint" | ||
"github.com/zmap/zlint/v3/util" | ||
) | ||
|
||
type subjectKeyIdNotRecommendedSubscriber struct{} | ||
|
||
/********************************************************************** | ||
RFC5280 suggested the addition of SKI extension, but CABF BR SC62 | ||
marked the extension as NOT RECOMMENDED for subscriber certificates | ||
Warning: | ||
Users of zlint will trigger either | ||
`w_ext_subject_key_identifier_not_recommended_subscriber` (this lint) | ||
or `w_ext_subject_key_identifier_missing_sub_cert` the one enforcing | ||
RFC5280's behavior. | ||
Users are expected to specifically ignore one or the other lint | ||
depending on which one apply to them. | ||
See: | ||
- https://github.com/zmap/zlint/issues/749 | ||
- https://github.com/zmap/zlint/issues/762 | ||
**********************************************************************/ | ||
|
||
func init() { | ||
lint.RegisterCertificateLint(&lint.CertificateLint{ | ||
LintMetadata: lint.LintMetadata{ | ||
Name: "w_ext_subject_key_identifier_not_recommended_subscriber", | ||
Description: "Subcriber certificates use of Subject Key Identifier is NOT RECOMMENDED", | ||
Citation: "BRs v2: 7.1.2.7.6", | ||
Source: lint.CABFBaselineRequirements, | ||
EffectiveDate: util.SC62EffectiveDate, | ||
}, | ||
Lint: NewSubjectKeyIdNotRecommendedSubscriber, | ||
}) | ||
} | ||
|
||
func NewSubjectKeyIdNotRecommendedSubscriber() lint.LintInterface { | ||
return &subjectKeyIdNotRecommendedSubscriber{} | ||
} | ||
|
||
func (l *subjectKeyIdNotRecommendedSubscriber) CheckApplies(cert *x509.Certificate) bool { | ||
return !util.IsCACert(cert) | ||
} | ||
|
||
func (l *subjectKeyIdNotRecommendedSubscriber) Execute(cert *x509.Certificate) *lint.LintResult { | ||
if util.IsExtInCert(cert, util.SubjectKeyIdentityOID) { | ||
return &lint.LintResult{Status: lint.Warn} | ||
} else { | ||
return &lint.LintResult{Status: lint.Pass} | ||
} | ||
} |