Skip to content

Commit f4d5b9e

Browse files
committed
Check and warn if CA certificate isn't marked as critical
1 parent 5bd1e5c commit f4d5b9e

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

shared/ssl/ssl.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type certificate struct {
9797
subjectKeyID string
9898
authKeyID string
9999
isCa bool
100+
isCritical bool
100101
isRoot bool
101102
}
102103

@@ -193,6 +194,8 @@ func extractCertificateData(content []byte) (certificate, error) {
193194
cert.authKeyID = strings.ToUpper(strings.TrimSpace(strings.SplitN(line, ":", 2)[1]))
194195
} else if nextVal == "basicConstraints" && strings.Contains(line, "CA:TRUE") {
195196
cert.isCa = true
197+
} else if nextVal == "basicConstraints" && strings.Contains(line, "critical") {
198+
cert.isCritical = true
196199
} else {
197200
// Unhandled extension value
198201
continue
@@ -206,6 +209,12 @@ func extractCertificateData(content []byte) (certificate, error) {
206209
}
207210
}
208211

212+
// This might not work anymore in the future.
213+
if cert.isCa && !cert.isCritical {
214+
// Translators: Don't translate `critical`
215+
log.Warn().Msgf(L("Basic constraints for CA should be marked as `critical`, could cause issues otherwise!"))
216+
}
217+
209218
if cert.subject == cert.issuer {
210219
cert.isRoot = true
211220
// Some Root CAs might not have their authorityKeyIdentifier set to themself
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Check and warn if CA certificate isn't marked as critical

0 commit comments

Comments
 (0)