@@ -340,21 +340,31 @@ def __init__(self, inner: _SigningConfig):
340
340
except ValueError :
341
341
raise Error (f"unsupported signing config format: { self ._inner .media_type } " )
342
342
343
- # currently not supporting other select modes
344
- # TODO: Support other modes ensuring tsa_urls() and tlog_urls() work
345
- if self ._inner .rekor_tlog_config .selector != ServiceSelector .ANY :
346
- raise Error (
347
- f"unsupported tlog selector { self ._inner .rekor_tlog_config .selector } "
348
- )
349
- if self ._inner .tsa_config .selector != ServiceSelector .ANY :
350
- raise Error (f"unsupported TSA selector { self ._inner .tsa_config .selector } " )
351
-
352
343
# Create lists of service protos that are valid & supported by this client
344
+ # Limit the TSA and tlog lists using the service selector config
353
345
self ._tlogs = self ._get_valid_services (
354
346
self ._inner .rekor_tlog_urls , REKOR_VERSIONS
355
347
)
348
+ if not self ._tlogs :
349
+ raise Error ("No valid Rekor transparency log found in signing config" )
350
+ if self ._inner .rekor_tlog_config .selector == ServiceSelector .EXACT :
351
+ if len (self ._tlogs ) < self ._inner .rekor_tlog_config .count :
352
+ raise Error (
353
+ "Not enough Rekor transparency logs found in signing config"
354
+ )
355
+ self ._tlogs = self ._tlogs [: self ._inner .rekor_tlog_config .count ]
356
+ elif self ._inner .rekor_tlog_config .selector == ServiceSelector .ANY :
357
+ self ._tlogs = self ._tlogs [:1 ]
358
+
356
359
self ._tsas = self ._get_valid_services (self ._inner .tsa_urls , TSA_VERSIONS )
360
+ if self ._inner .tsa_config .selector == ServiceSelector .EXACT :
361
+ self ._tsas = self ._tsas [: self ._inner .tsa_config .count ]
362
+ elif self ._inner .tsa_config .selector == ServiceSelector .ANY :
363
+ self ._tsas = self ._tsas [:1 ]
364
+
357
365
self ._fulcios = self ._get_valid_services (self ._inner .ca_urls , FULCIO_VERSIONS )
366
+ if not self ._fulcios :
367
+ raise Error ("No valid Fulcio CA found in signing config" )
358
368
self ._oidcs = self ._get_valid_services (self ._inner .oidc_urls , OIDC_VERSIONS )
359
369
360
370
@classmethod
@@ -397,18 +407,13 @@ def get_tlogs(self) -> list[RekorClient]:
397
407
"""
398
408
Returns the rekor transparency logs that client should sign with.
399
409
"""
400
-
401
- if not self ._tlogs :
402
- raise Error ("No valid Rekor transparency log found in signing config" )
403
410
return [RekorClient (tlog .url ) for tlog in self ._tlogs ]
404
411
405
412
def get_fulcio (self ) -> FulcioClient :
406
413
"""
407
414
Returns url for the fulcio instance that client should use to get a
408
415
signing certificate from
409
416
"""
410
- if not self ._fulcios :
411
- raise Error ("No valid Fulcio CA found in signing config" )
412
417
return FulcioClient (self ._fulcios [0 ].url )
413
418
414
419
def get_oidc_url (self ) -> str :
0 commit comments