From 110fc8dbbb60bb800f7155b6cc07743742159b35 Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Fri, 1 Nov 2024 10:30:27 +0800 Subject: [PATCH] add crl logs Signed-off-by: Patrick Zheng --- verifier/crl/crl.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/verifier/crl/crl.go b/verifier/crl/crl.go index 9ebd16db..7cbe384d 100644 --- a/verifier/crl/crl.go +++ b/verifier/crl/crl.go @@ -88,32 +88,38 @@ func (c *FileCache) Get(ctx context.Context, url string) (*corecrl.Bundle, error 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 } } @@ -127,9 +133,11 @@ func (c *FileCache) Set(ctx context.Context, url string, bundle *corecrl.Bundle) 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") } @@ -142,9 +150,11 @@ func (c *FileCache) Set(ctx context.Context, url string, bundle *corecrl.Bundle) } contentBytes, err := json.Marshal(content) if 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) } if err := file.WriteFile(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