Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions shared/ssl/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
}

// Extract data from the certificate to help ordering and verifying it.
func extractCertificateData(content []byte) (certificate, error) {

Check failure on line 141 in shared/ssl/ssl.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 38 to the 35 allowed.

See more on https://sonarcloud.io/project/issues?id=uyuni-project_uyuni-tools&issues=AZ6D6U8j67szitEHz3Yy&open=AZ6D6U8j67szitEHz3Yy&pullRequest=803
args := []string{"x509", "-noout", "-subject", "-subject_hash", "-startdate", "-enddate",
"-issuer", "-issuer_hash", "-ext", "subjectKeyIdentifier,authorityKeyIdentifier,basicConstraints"}
log.Debug().Msg("Running command openssl " + strings.Join(args, " "))
Expand Down Expand Up @@ -192,6 +192,9 @@
} else if nextVal == "authKeyId" && strings.HasPrefix(line, " keyid:") {
cert.authKeyID = strings.ToUpper(strings.TrimSpace(strings.SplitN(line, ":", 2)[1]))
} else if nextVal == "basicConstraints" && strings.Contains(line, "CA:TRUE") {
if !strings.Contains(line, "critical") {
log.Error().Msg(L("CA basicConstraints section is not marked as 'critical'"))
}
cert.isCa = true
} else {
// Unhandled extension value
Expand Down
1 change: 1 addition & 0 deletions uyuni-tools.changes.cbosdo.critical-check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Report error if CA misses critical basicConstraints
Loading