18
18
import com .google .api .client .util .Preconditions ;
19
19
import com .google .common .hash .Hashing ;
20
20
import com .google .common .io .Files ;
21
- import dev .sigstore .KeylessVerificationRequest .VerificationOptions ;
22
21
import dev .sigstore .encryption .certificates .Certificates ;
23
22
import dev .sigstore .encryption .signers .Verifiers ;
24
23
import dev .sigstore .fulcio .client .FulcioCertificateVerifier ;
@@ -90,35 +89,6 @@ public Builder sigstoreStagingDefaults() throws IOException {
90
89
}
91
90
}
92
91
93
- /**
94
- * Verify that the inputs can attest to the validity of a signature using sigstore's keyless
95
- * infrastructure. If no exception is thrown, it should be assumed verification has passed.
96
- *
97
- * @param artifactDigest the sha256 digest of the artifact that was signed
98
- * @param certChain the certificate chain obtained from a fulcio instance
99
- * @param signature the signature on the artifact
100
- * @throws KeylessVerificationException if the signing information could not be verified
101
- */
102
- @ Deprecated
103
- public void verifyOnline (byte [] artifactDigest , byte [] certChain , byte [] signature )
104
- throws KeylessVerificationException {
105
- try {
106
- verify (
107
- artifactDigest ,
108
- KeylessVerificationRequest .builder ()
109
- .keylessSignature (
110
- KeylessSignature .builder ()
111
- .signature (signature )
112
- .certPath (Certificates .fromPemChain (certChain ))
113
- .digest (artifactDigest )
114
- .build ())
115
- .verificationOptions (VerificationOptions .builder ().isOnline (true ).build ())
116
- .build ());
117
- } catch (CertificateException ex ) {
118
- throw new KeylessVerificationException ("Certificate was not valid: " + ex .getMessage (), ex );
119
- }
120
- }
121
-
122
92
/** Convenience wrapper around {@link #verify(byte[], KeylessVerificationRequest)}. */
123
93
public void verify (Path artifact , KeylessVerificationRequest request )
124
94
throws KeylessVerificationException {
@@ -181,34 +151,11 @@ public void verify(byte[] artifactDigest, KeylessVerificationRequest request)
181
151
182
152
var signature = request .getKeylessSignature ().getSignature ();
183
153
184
- // Logic is a bit convoluted for obtaining rekor entry for further processing
185
- // 1. if we're in "online mode":
186
- // a. grab the entry from rekor remote to use for verification
187
- // b. if an entry was also provided directly to this library, verify it is valid and the
188
- // same signable content as the one we obtained from rekor. SETs will be different
189
- // because rekor can generate those using a non-idempotent signer, but all signatures
190
- // should still be valid
191
- // 2. if we're in offline mode, ensure an entry was provided
192
-
193
154
RekorEntry rekorEntry ;
194
-
195
- if (request .getVerificationOptions ().isOnline ()) {
155
+ if (request .getVerificationOptions ().alwaysUseRemoteRekorEntry ()
156
+ || request .getKeylessSignature ().getEntry ().isEmpty ()) {
157
+ // this setting means we ignore any provided entry
196
158
rekorEntry = getEntryFromRekor (artifactDigest , leafCert , signature );
197
- if (request .getKeylessSignature ().getEntry ().isPresent ()) {
198
- var provided = request .getKeylessSignature ().getEntry ().get ();
199
- if (!Arrays .equals (
200
- rekorEntry .getSignableContent (),
201
- request .getKeylessSignature ().getEntry ().get ().getSignableContent ())) {
202
- throw new KeylessVerificationException (
203
- "Entry obtained from rekor does not match provided entry" );
204
- }
205
- // verify the provided rekor entry is valid even if we are in online mode
206
- try {
207
- rekorVerifier .verifyEntry (provided );
208
- } catch (RekorVerificationException ex ) {
209
- throw new KeylessVerificationException ("Rekor entry signature was not valid" );
210
- }
211
- }
212
159
} else {
213
160
rekorEntry =
214
161
request
@@ -234,8 +181,8 @@ public void verify(byte[] artifactDigest, KeylessVerificationRequest request)
234
181
} catch (RekorVerificationException ex ) {
235
182
throw new KeylessVerificationException ("Rekor entry inclusion proof was not valid" );
236
183
}
237
- } else if (request .getVerificationOptions ().isOnline ()) {
238
- throw new KeylessVerificationException ("Fetched rekor entry did not contain inclusion proof" );
184
+ } else if (request .getVerificationOptions ().alwaysUseRemoteRekorEntry ()) {
185
+ throw new KeylessVerificationException ("Rekor entry did not contain inclusion proof" );
239
186
}
240
187
241
188
// check if the time of entry inclusion in the log (a stand-in for signing time) is within the
0 commit comments