Skip to content

Commit

Permalink
fix: simplify code
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <[email protected]>
  • Loading branch information
JeyJeyGao committed Dec 9, 2024
1 parent 630c7a5 commit ad51cf8
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions revocation/crl/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func (f *HTTPFetcher) fetch(ctx context.Context, url string) (*Bundle, error) {
//
// It returns errDeltaCRLNotFound if the delta CRL is not found.
func (f *HTTPFetcher) fetchDeltaCRL(extensions *[]pkix.Extension) (*x509.RevocationList, error) {
var (
lastError error
deltaCRL *x509.RevocationList
)
for _, ext := range *extensions {
if ext.Id.Equal(oidFreshestCRL) {
// RFC 5280, 4.2.1.15
Expand All @@ -152,28 +156,23 @@ func (f *HTTPFetcher) fetchDeltaCRL(extensions *[]pkix.Extension) (*x509.Revocat
if err != nil {
return nil, fmt.Errorf("failed to parse Freshest CRL extension: %w", err)
}
if len(urls) == 0 {
return nil, errDeltaCRLNotFound
}

var (
lastError error
deltaCRL *x509.RevocationList
)
for _, cdpURL := range urls {
// RFC 5280, 5.2.6
// Delta CRLs from the base CRL have the same scope as the base
// CRL, so the URLs are for redundancy and should be tried in
// order until one succeeds.
deltaCRL, lastError = fetchCRL(context.Background(), cdpURL, f.httpClient)
if lastError != nil {
continue
if lastError == nil {
return deltaCRL, nil
}
return deltaCRL, nil
}
return nil, lastError
break
}
}
if lastError != nil {
return nil, lastError
}
return nil, errDeltaCRLNotFound
}

Expand Down

0 comments on commit ad51cf8

Please sign in to comment.