Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add crl cache debug logs #473

Merged
merged 3 commits into from
Nov 3, 2024
Merged
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
10 changes: 10 additions & 0 deletions verifier/crl/crl.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,32 +88,38 @@
logger.Debugf("CRL file cache miss. Key %q does not exist", url)
return nil, corecrl.ErrCacheMiss
}
logger.Debugf("failed to get crl bundle from file cache with key %q: %w", url, err)
return nil, fmt.Errorf("failed to get crl bundle from file cache with key %q: %w", url, err)
}

// decode content to crl Bundle
var content fileCacheContent
if err := json.Unmarshal(contentBytes, &content); err != nil {
logger.Debugf("failed to decode file retrieved from file cache: %w", err)
return nil, fmt.Errorf("failed to decode file retrieved from file cache: %w", err)
}
var bundle corecrl.Bundle
bundle.BaseCRL, err = x509.ParseRevocationList(content.BaseCRL)
if err != nil {
logger.Debugf("failed to parse base CRL of file retrieved from file cache: %w", err)
return nil, fmt.Errorf("failed to parse base CRL of file retrieved from file cache: %w", err)
}
if content.DeltaCRL != nil {
bundle.DeltaCRL, err = x509.ParseRevocationList(content.DeltaCRL)
if err != nil {
logger.Debugf("failed to parse delta CRL of file retrieved from file cache: %w", err)
return nil, fmt.Errorf("failed to parse delta CRL of file retrieved from file cache: %w", err)
}
}

// check expiry
if err := checkExpiry(ctx, bundle.BaseCRL.NextUpdate); err != nil {
logger.Debugf("check BaseCRL expiry failed: %w", err)
return nil, err
}
if bundle.DeltaCRL != nil {
if err := checkExpiry(ctx, bundle.DeltaCRL.NextUpdate); err != nil {
logger.Debugf("check DeltaCRL expiry failed: %w", err)
return nil, err
}
}
Expand All @@ -127,9 +133,11 @@
logger.Debugf("Storing crl bundle to file cache with key %q ...", url)

if bundle == nil {
logger.Debugln("failed to store crl bundle in file cache: bundle cannot be nil")
return errors.New("failed to store crl bundle in file cache: bundle cannot be nil")
}
if bundle.BaseCRL == nil {
logger.Debugln("failed to store crl bundle in file cache: bundle BaseCRL cannot be nil")
return errors.New("failed to store crl bundle in file cache: bundle BaseCRL cannot be nil")
}

Expand All @@ -142,9 +150,11 @@
}
contentBytes, err := json.Marshal(content)
if err != nil {
logger.Debugf("failed to store crl bundle in file cache: %w", err)

Check warning on line 153 in verifier/crl/crl.go

View check run for this annotation

Codecov / codecov/patch

verifier/crl/crl.go#L153

Added line #L153 was not covered by tests
return fmt.Errorf("failed to store crl bundle in file cache: %w", err)
}
if err := file.WriteFile(c.root, filepath.Join(c.root, c.fileName(url)), contentBytes); err != nil {
logger.Debugf("failed to store crl bundle in file cache: %w", err)
return fmt.Errorf("failed to store crl bundle in file cache: %w", err)
}
return nil
Expand Down
Loading