27
27
from rich .logging import RichHandler
28
28
29
29
from sigstore import __version__ , dsse
30
- from sigstore ._internal .fulcio .client import (
31
- DEFAULT_FULCIO_URL ,
32
- ExpiredCertificate ,
33
- FulcioClient ,
34
- )
30
+ from sigstore ._internal .fulcio .client import ExpiredCertificate
35
31
from sigstore ._internal .rekor import _hashedrekord_from_parts
36
- from sigstore ._internal .rekor .client import (
37
- DEFAULT_REKOR_URL ,
38
- RekorClient ,
39
- )
40
- from sigstore ._internal .trustroot import KeyringPurpose , TrustedRoot
32
+ from sigstore ._internal .trust import ClientTrustConfig
41
33
from sigstore ._utils import sha256_digest
42
34
from sigstore .errors import Error , VerificationError
43
35
from sigstore .hashes import Hashed
44
36
from sigstore .models import Bundle
45
37
from sigstore .oidc import (
46
38
DEFAULT_OAUTH_ISSUER_URL ,
47
- STAGING_OAUTH_ISSUER_URL ,
48
39
ExpiredIdentity ,
49
40
IdentityToken ,
50
41
Issuer ,
@@ -95,35 +86,6 @@ def _boolify_env(envvar: str) -> bool:
95
86
raise ValueError (f"can't coerce '{ val } ' to a boolean" )
96
87
97
88
98
- def _add_shared_instance_options (group : argparse ._ArgumentGroup ) -> None :
99
- """
100
- Common Sigstore instance options, shared between all `sigstore` subcommands.
101
- """
102
- group .add_argument (
103
- "--staging" ,
104
- dest = "__deprecated_staging" ,
105
- action = "store_true" ,
106
- default = False ,
107
- help = (
108
- "Use sigstore's staging instances, instead of the default production instances. "
109
- "This option will be deprecated in favor of the global `--staging` option "
110
- "in a future release."
111
- ),
112
- )
113
- group .add_argument (
114
- "--rekor-url" ,
115
- dest = "__deprecated_rekor_url" ,
116
- metavar = "URL" ,
117
- type = str ,
118
- default = None ,
119
- help = (
120
- "The Rekor instance to use (conflicts with --staging). "
121
- "This option will be deprecated in favor of the global `--rekor-url` option "
122
- "in a future release."
123
- ),
124
- )
125
-
126
-
127
89
def _add_shared_verify_input_options (group : argparse ._ArgumentGroup ) -> None :
128
90
"""
129
91
Common input options, shared between all `sigstore verify` subcommands.
@@ -230,21 +192,19 @@ def _parser() -> argparse.ArgumentParser:
230
192
"-V" , "--version" , action = "version" , version = f"sigstore { __version__ } "
231
193
)
232
194
233
- global_instance_options = parser .add_argument_group ( "Sigstore instance options" )
195
+ global_instance_options = parser .add_mutually_exclusive_group ( )
234
196
global_instance_options .add_argument (
235
197
"--staging" ,
236
198
action = "store_true" ,
237
199
default = _boolify_env ("SIGSTORE_STAGING" ),
238
200
help = "Use sigstore's staging instances, instead of the default production instances" ,
239
201
)
240
202
global_instance_options .add_argument (
241
- "--rekor-url" ,
242
- metavar = "URL" ,
243
- type = str ,
244
- default = os .getenv ("SIGSTORE_REKOR_URL" , DEFAULT_REKOR_URL ),
245
- help = "The Rekor instance to use (conflicts with --staging)" ,
203
+ "--trust-config" ,
204
+ metavar = "FILE" ,
205
+ type = Path ,
206
+ help = "The client trust configuration to use" ,
246
207
)
247
-
248
208
subcommands = parser .add_subparsers (
249
209
required = True ,
250
210
dest = "subcommand" ,
@@ -324,16 +284,6 @@ def _parser() -> argparse.ArgumentParser:
324
284
help = "Overwrite preexisting signature and certificate outputs, if present" ,
325
285
)
326
286
327
- instance_options = sign .add_argument_group ("Sigstore instance options" )
328
- _add_shared_instance_options (instance_options )
329
- instance_options .add_argument (
330
- "--fulcio-url" ,
331
- metavar = "URL" ,
332
- type = str ,
333
- default = os .getenv ("SIGSTORE_FULCIO_URL" , DEFAULT_FULCIO_URL ),
334
- help = "The Fulcio instance to use (conflicts with --staging)" ,
335
- )
336
-
337
287
sign .add_argument (
338
288
"files" ,
339
289
metavar = "FILE" ,
@@ -385,9 +335,6 @@ def _parser() -> argparse.ArgumentParser:
385
335
required = True ,
386
336
)
387
337
388
- instance_options = verify_identity .add_argument_group ("Sigstore instance options" )
389
- _add_shared_instance_options (instance_options )
390
-
391
338
# `sigstore verify github`
392
339
verify_github = verify_subcommand .add_parser (
393
340
"github" ,
@@ -449,9 +396,6 @@ def _parser() -> argparse.ArgumentParser:
449
396
help = "The `git` ref that the workflow was invoked with" ,
450
397
)
451
398
452
- instance_options = verify_github .add_argument_group ("Sigstore instance options" )
453
- _add_shared_instance_options (instance_options )
454
-
455
399
# `sigstore get-identity-token`
456
400
get_identity_token = subcommands .add_parser (
457
401
"get-identity-token" ,
@@ -476,22 +420,6 @@ def main() -> None:
476
420
477
421
_logger .debug (f"parsed arguments { args } " )
478
422
479
- # A few instance flags (like `--staging` and `--rekor-url`) are supported at both the
480
- # top-level `sigstore` level and the subcommand level (e.g. `sigstore verify --staging`),
481
- # but the former is preferred.
482
- if getattr (args , "__deprecated_staging" , False ):
483
- _logger .warning (
484
- "`--staging` should be used as a global option, rather than a subcommand option. "
485
- "Passing `--staging` as a subcommand option will be deprecated in a future release."
486
- )
487
- args .staging = args .__deprecated_staging
488
- if getattr (args , "__deprecated_rekor_url" , None ):
489
- _logger .warning (
490
- "`--rekor-url` should be used as a global option, rather than a subcommand option. "
491
- "Passing `--rekor-url` as a subcommand option will be deprecated in a future release."
492
- )
493
- args .rekor_url = args .__deprecated_rekor_url
494
-
495
423
# Stuff the parser back into our namespace, so that we can use it for
496
424
# error handling later.
497
425
args ._parser = parser
@@ -594,18 +522,14 @@ def _sign(args: argparse.Namespace) -> None:
594
522
if args .staging :
595
523
_logger .debug ("sign: staging instances requested" )
596
524
signing_ctx = SigningContext .staging ()
597
- args .oidc_issuer = STAGING_OAUTH_ISSUER_URL
598
- elif args . fulcio_url == DEFAULT_FULCIO_URL and args . rekor_url == DEFAULT_REKOR_URL :
599
- signing_ctx = SigningContext .production ( )
525
+ elif args .trust_config :
526
+ trust_config = ClientTrustConfig . from_json ( args . trust_config . read_text ())
527
+ signing_ctx = SigningContext ._from_trust_config ( trust_config )
600
528
else :
601
- # Assume "production" trust root if no keys are given as arguments
602
- trusted_root = TrustedRoot .production (purpose = KeyringPurpose .SIGN )
603
-
604
- signing_ctx = SigningContext (
605
- fulcio = FulcioClient (args .fulcio_url ),
606
- rekor = RekorClient (args .rekor_url ),
607
- trusted_root = trusted_root ,
608
- )
529
+ # If the user didn't request the staging instance or pass in an
530
+ # explicit client trust config, we're using the public good (i.e.
531
+ # production) instance.
532
+ signing_ctx = SigningContext .production ()
609
533
610
534
# The order of precedence for identities is as follows:
611
535
#
@@ -745,8 +669,8 @@ def _collect_verification_state(
745
669
missing .append (str (cert ))
746
670
input_map [file ] = {"cert" : cert , "sig" : sig }
747
671
else :
748
- # If a user hasn't explicitly supplied `--signature`, `--certificate` or
749
- # `--rekor-bundle`, we expect a bundle either supplied via `--bundle` or with the
672
+ # If a user hasn't explicitly supplied `--signature` or `--certificate`,
673
+ # we expect a bundle either supplied via `--bundle` or with the
750
674
# default `{input}.sigstore(.json)?` name.
751
675
if not bundle .is_file ():
752
676
missing .append (str (bundle ))
@@ -761,16 +685,11 @@ def _collect_verification_state(
761
685
if args .staging :
762
686
_logger .debug ("verify: staging instances requested" )
763
687
verifier = Verifier .staging ()
764
- elif args .rekor_url == DEFAULT_REKOR_URL :
765
- verifier = Verifier .production ()
688
+ elif args .trust_config :
689
+ trust_config = ClientTrustConfig .from_json (args .trust_config .read_text ())
690
+ verifier = Verifier ._from_trust_config (trust_config )
766
691
else :
767
- trusted_root = TrustedRoot .production (purpose = KeyringPurpose .VERIFY )
768
- verifier = Verifier (
769
- rekor = RekorClient (
770
- url = args .rekor_url ,
771
- ),
772
- trusted_root = trusted_root ,
773
- )
692
+ verifier = Verifier .production ()
774
693
775
694
all_materials = []
776
695
for file , inputs in input_map .items ():
0 commit comments