Skip to content

Commit 519e58a

Browse files
marv7000mcalmer
authored andcommitted
Check and warn if CA certificate isn't marked as critical
1 parent 464fb47 commit 519e58a

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

shared/ssl/ssl.go

Lines changed: 8 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,11 @@ func extractCertificateData(content []byte) (certificate, error) {
206209
}
207210
}
208211

212+
// This configuration might not work anymore in the future.
213+
if cert.isCa && !cert.isCritical {
214+
log.Warn().Msgf(L("Basic constraints for CA should be marked as `%s`, could cause issues otherwise!"), "critical")
215+
}
216+
209217
if cert.subject == cert.issuer {
210218
cert.isRoot = true
211219
// 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)