@@ -25,11 +25,11 @@ import (
2525 "io"
2626 "net/http"
2727 "net/url"
28- "slices"
2928 "time"
3029
30+ "github.com/notaryproject/notation-core-go/revocation/internal/x509util"
3131 "golang.org/x/crypto/cryptobyte"
32- cryptobyte_asn1 "golang.org/x/crypto/cryptobyte/asn1"
32+ cbasn1 "golang.org/x/crypto/cryptobyte/asn1"
3333)
3434
3535// oidFreshestCRL is the object identifier for the distribution point
@@ -142,17 +142,16 @@ func (f *HTTPFetcher) fetch(ctx context.Context, url string) (*Bundle, error) {
142142//
143143// It returns errDeltaCRLNotFound if the delta CRL is not found.
144144func (f * HTTPFetcher ) fetchDeltaCRL (ctx context.Context , extensions []pkix.Extension ) (* x509.RevocationList , error ) {
145- idx := slices .IndexFunc (extensions , func (ext pkix.Extension ) bool {
146- return ext .Id .Equal (oidFreshestCRL )
147- })
148- if idx < 0 {
145+ extension := x509util .FindExtensionByOID (oidFreshestCRL , extensions )
146+ if extension == nil {
149147 return nil , errDeltaCRLNotFound
150148 }
149+
151150 // RFC 5280, 4.2.1.15
152151 // id-ce-freshestCRL OBJECT IDENTIFIER ::= { id-ce 46 }
153152 //
154153 // FreshestCRL ::= CRLDistributionPoints
155- urls , err := parseCRLDistributionPoint (extensions [ idx ] .Value )
154+ urls , err := parseCRLDistributionPoint (extension .Value )
156155 if err != nil {
157156 return nil , fmt .Errorf ("failed to parse Freshest CRL extension: %w" , err )
158157 }
@@ -197,31 +196,31 @@ func parseCRLDistributionPoint(value []byte) ([]string, error) {
197196 // fullName [0] GeneralNames,
198197 // nameRelativeToCRLIssuer [1] RelativeDistinguishedName }
199198 val := cryptobyte .String (value )
200- if ! val .ReadASN1 (& val , cryptobyte_asn1 .SEQUENCE ) {
199+ if ! val .ReadASN1 (& val , cbasn1 .SEQUENCE ) {
201200 return nil , errors .New ("x509: invalid CRL distribution points" )
202201 }
203202 for ! val .Empty () {
204203 var dpDER cryptobyte.String
205- if ! val .ReadASN1 (& dpDER , cryptobyte_asn1 .SEQUENCE ) {
204+ if ! val .ReadASN1 (& dpDER , cbasn1 .SEQUENCE ) {
206205 return nil , errors .New ("x509: invalid CRL distribution point" )
207206 }
208207 var dpNameDER cryptobyte.String
209208 var dpNamePresent bool
210- if ! dpDER .ReadOptionalASN1 (& dpNameDER , & dpNamePresent , cryptobyte_asn1 .Tag (0 ).Constructed ().ContextSpecific ()) {
209+ if ! dpDER .ReadOptionalASN1 (& dpNameDER , & dpNamePresent , cbasn1 .Tag (0 ).Constructed ().ContextSpecific ()) {
211210 return nil , errors .New ("x509: invalid CRL distribution point" )
212211 }
213212 if ! dpNamePresent {
214213 continue
215214 }
216- if ! dpNameDER .ReadASN1 (& dpNameDER , cryptobyte_asn1 .Tag (0 ).Constructed ().ContextSpecific ()) {
215+ if ! dpNameDER .ReadASN1 (& dpNameDER , cbasn1 .Tag (0 ).Constructed ().ContextSpecific ()) {
217216 return nil , errors .New ("x509: invalid CRL distribution point" )
218217 }
219218 for ! dpNameDER .Empty () {
220- if ! dpNameDER .PeekASN1Tag (cryptobyte_asn1 .Tag (6 ).ContextSpecific ()) {
219+ if ! dpNameDER .PeekASN1Tag (cbasn1 .Tag (6 ).ContextSpecific ()) {
221220 break
222221 }
223222 var uri cryptobyte.String
224- if ! dpNameDER .ReadASN1 (& uri , cryptobyte_asn1 .Tag (6 ).ContextSpecific ()) {
223+ if ! dpNameDER .ReadASN1 (& uri , cbasn1 .Tag (6 ).ContextSpecific ()) {
225224 return nil , errors .New ("x509: invalid CRL distribution point" )
226225 }
227226 urls = append (urls , string (uri ))
0 commit comments