@@ -340,23 +340,32 @@ 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 ("Not enough Rekor transparency logs found in signing config" )
353
+ self ._tlogs = self ._tlogs [:self ._inner .rekor_tlog_config .count ]
354
+ elif self ._inner .rekor_tlog_config .selector == ServiceSelector .ANY :
355
+ self ._tlogs = self ._tlogs [:1 ]
356
+
356
357
self ._tsas = self ._get_valid_services (self ._inner .tsa_urls , TSA_VERSIONS )
358
+ if self ._inner .tsa_config .selector == ServiceSelector .EXACT :
359
+ self ._tsas = self ._tsas [:self ._inner .tsa_config .count ]
360
+ elif self ._inner .tsa_config .selector == ServiceSelector .ANY :
361
+ self ._tsas = self ._tsas [:1 ]
362
+
357
363
self ._fulcios = self ._get_valid_services (self ._inner .ca_urls , FULCIO_VERSIONS )
364
+ if not self ._fulcios :
365
+ raise Error ("No valid Fulcio CA found in signing config" )
358
366
self ._oidcs = self ._get_valid_services (self ._inner .oidc_urls , OIDC_VERSIONS )
359
367
368
+
360
369
@classmethod
361
370
def from_file (
362
371
cls ,
@@ -397,18 +406,13 @@ def get_tlogs(self) -> list[RekorClient]:
397
406
"""
398
407
Returns the rekor transparency logs that client should sign with.
399
408
"""
400
-
401
- if not self ._tlogs :
402
- raise Error ("No valid Rekor transparency log found in signing config" )
403
409
return [RekorClient (tlog .url ) for tlog in self ._tlogs ]
404
410
405
411
def get_fulcio (self ) -> FulcioClient :
406
412
"""
407
413
Returns url for the fulcio instance that client should use to get a
408
414
signing certificate from
409
415
"""
410
- if not self ._fulcios :
411
- raise Error ("No valid Fulcio CA found in signing config" )
412
416
return FulcioClient (self ._fulcios [0 ].url )
413
417
414
418
def get_oidc_url (self ) -> str :
0 commit comments