23
23
import dev .sigstore .VerificationOptions ;
24
24
import dev .sigstore .VerificationOptions .CertificateMatcher ;
25
25
import dev .sigstore .bundle .Bundle ;
26
- import dev .sigstore .bundle .Bundle .HashAlgorithm ;
27
- import dev .sigstore .bundle .Bundle .MessageSignature ;
28
- import dev .sigstore .bundle .ImmutableBundle ;
29
- import dev .sigstore .encryption .certificates .Certificates ;
30
- import dev .sigstore .rekor .client .RekorEntryFetcher ;
31
26
import dev .sigstore .strings .StringMatcher ;
32
27
import dev .sigstore .tuf .RootProvider ;
33
28
import dev .sigstore .tuf .SigstoreTufClient ;
34
29
import java .net .URL ;
35
30
import java .nio .charset .StandardCharsets ;
36
- import java .nio .file .Files ;
37
31
import java .nio .file .Path ;
38
- import java .security .cert .CertPath ;
39
- import java .util .Base64 ;
40
32
import java .util .concurrent .Callable ;
41
33
import org .apache .commons .codec .binary .Hex ;
42
34
import picocli .CommandLine .ArgGroup ;
@@ -58,8 +50,11 @@ public class Verify implements Callable<Integer> {
58
50
description = "an artifact path or artifact hash (sha256:abc...) to verify" )
59
51
String artifact ;
60
52
61
- @ ArgGroup (multiplicity = "1" , exclusive = true )
62
- SignatureFiles signatureFiles ;
53
+ @ Option (
54
+ names = {"--bundle" },
55
+ description = "path to bundle file" ,
56
+ required = true )
57
+ Path bundleFile ;
63
58
64
59
@ ArgGroup (multiplicity = "0..1" , exclusive = false )
65
60
Policy policy ;
@@ -119,29 +114,7 @@ public Integer call() throws Exception {
119
114
? Hex .decodeHex (artifact .substring (SHA256_PREFIX .length ()))
120
115
: asByteSource (Path .of (artifact ).toFile ()).hash (Hashing .sha256 ()).asBytes ();
121
116
122
- Bundle bundle ;
123
- if (signatureFiles .sigAndCert != null ) {
124
- byte [] signature =
125
- Base64 .getMimeDecoder ()
126
- .decode (Files .readAllBytes (signatureFiles .sigAndCert .signatureFile ));
127
- CertPath certPath =
128
- Certificates .fromPemChain (Files .readAllBytes (signatureFiles .sigAndCert .certificateFile ));
129
- RekorEntryFetcher fetcher =
130
- target == null
131
- ? RekorEntryFetcher .sigstorePublicGood ()
132
- : target .staging
133
- ? RekorEntryFetcher .sigstoreStaging ()
134
- : RekorEntryFetcher .fromTrustedRoot (target .trustedRoot );
135
- bundle =
136
- ImmutableBundle .builder ()
137
- .messageSignature (MessageSignature .of (HashAlgorithm .SHA2_256 , digest , signature ))
138
- .certPath (certPath )
139
- .addEntries (
140
- fetcher .getEntryFromRekor (digest , Certificates .getLeaf (certPath ), signature ))
141
- .build ();
142
- } else {
143
- bundle = Bundle .from (signatureFiles .bundleFile , StandardCharsets .UTF_8 );
144
- }
117
+ Bundle bundle = Bundle .from (bundleFile , StandardCharsets .UTF_8 );
145
118
146
119
var verificationOptionsBuilder = VerificationOptions .builder ();
147
120
if (policy != null ) {
0 commit comments