@@ -342,25 +342,27 @@ def __init__(self, inner: _SigningConfig):
342
342
343
343
# Create lists of service protos that are valid & supported by this client
344
344
# Limit the TSA and tlog lists using the service selector config
345
- self ._tlogs = self ._get_valid_services (
346
- self ._inner .rekor_tlog_urls , REKOR_VERSIONS
347
- )
348
- if not self ._tlogs :
345
+ tlogs = self ._get_valid_services (self ._inner .rekor_tlog_urls , REKOR_VERSIONS )
346
+ if not tlogs :
349
347
raise Error ("No valid Rekor transparency log found in signing config" )
350
348
if self ._inner .rekor_tlog_config .selector == ServiceSelector .EXACT :
351
- if len (self . _tlogs ) < self ._inner .rekor_tlog_config .count :
349
+ if len (tlogs ) < self ._inner .rekor_tlog_config .count :
352
350
raise Error (
353
351
"Not enough Rekor transparency logs found in signing config"
354
352
)
355
- self ._tlogs = self . _tlogs [: self ._inner .rekor_tlog_config .count ]
353
+ self ._tlogs = tlogs [: self ._inner .rekor_tlog_config .count ]
356
354
elif self ._inner .rekor_tlog_config .selector == ServiceSelector .ANY :
357
- self ._tlogs = self ._tlogs [:1 ]
355
+ self ._tlogs = tlogs [:1 ]
356
+ else :
357
+ self ._tlogs = tlogs
358
358
359
- self . _tsas = self ._get_valid_services (self ._inner .tsa_urls , TSA_VERSIONS )
359
+ tsas = self ._get_valid_services (self ._inner .tsa_urls , TSA_VERSIONS )
360
360
if self ._inner .tsa_config .selector == ServiceSelector .EXACT :
361
- self ._tsas = self . _tsas [: self ._inner .tsa_config .count ]
361
+ self ._tsas = tsas [: self ._inner .tsa_config .count ]
362
362
elif self ._inner .tsa_config .selector == ServiceSelector .ANY :
363
- self ._tsas = self ._tsas [:1 ]
363
+ self ._tsas = tsas [:1 ]
364
+ else :
365
+ self ._tsas = tsas
364
366
365
367
self ._fulcios = self ._get_valid_services (self ._inner .ca_urls , FULCIO_VERSIONS )
366
368
if not self ._fulcios :
@@ -395,7 +397,7 @@ def _get_valid_services(
395
397
# return a list of services but make sure we only return logs of one version per operator
396
398
result : list [Service ] = []
397
399
for logs in logs_by_operator .values ():
398
- logs .sort (key = lambda s : s .major_api_version )
400
+ logs .sort (key = lambda s : - s .major_api_version )
399
401
max_version = logs [- 1 ].major_api_version
400
402
401
403
while logs and logs [- 1 ].major_api_version == max_version :
0 commit comments