@@ -37,6 +37,8 @@ import (
37
37
"github.com/sigstore/cosign/pkg/cosign/pkcs11key"
38
38
"github.com/sigstore/cosign/pkg/oci"
39
39
sigs "github.com/sigstore/cosign/pkg/signature"
40
+ rekorclient "github.com/sigstore/rekor/pkg/generated/client"
41
+ "github.com/sigstore/sigstore/pkg/signature"
40
42
"github.com/sigstore/sigstore/pkg/signature/payload"
41
43
)
42
44
@@ -129,8 +131,8 @@ func validate(cfg *Config) func(w http.ResponseWriter, req *http.Request) {
129
131
}
130
132
131
133
type checkedMetadata struct {
132
- ImageSignatures []payload.SimpleContainerImage `json:"imageSignatures "`
133
- AttestationSignatures []in_toto.Statement `json:"attestationSignatures "`
134
+ Signatures []payload.SimpleContainerImage `json:"signatures "`
135
+ Attestations []in_toto.Statement `json:"attestations "`
134
136
}
135
137
136
138
func verifyImageSignatures (ctx context.Context , key string , verifiers []Verifier ) (* checkedMetadata , error ) {
@@ -149,17 +151,19 @@ func verifyImageSignatures(ctx context.Context, key string, verifiers []Verifier
149
151
RootCerts : fulcio .GetRoots (),
150
152
}
151
153
if o .Options .RekorURL != "" {
152
- rekorClient , err := rekor .NewClient (o .Options .RekorURL )
154
+ var rekorClient * rekorclient.Rekor
155
+ rekorClient , err = rekor .NewClient (o .Options .RekorURL )
153
156
if err != nil {
154
- return nil , fmt .Errorf ("rekor.NewClient : %v" , err )
157
+ return nil , fmt .Errorf ("creating rekor client : %v" , err )
155
158
}
156
159
co .RekorClient = rekorClient
157
- fmt .Printf ("using rekor url %s to verify %s\n " , o .Options .RekorURL , key )
160
+ fmt .Printf ("error using rekor url %s to verify %s\n " , o .Options .RekorURL , key )
158
161
}
159
162
if o .Options .Key != "" {
160
- pubKey , err := sigs .PublicKeyFromKeyRef (ctx , o .Options .Key )
163
+ var pubKey signature.Verifier
164
+ pubKey , err = sigs .PublicKeyFromKeyRef (ctx , o .Options .Key )
161
165
if err != nil {
162
- return nil , fmt .Errorf ("publicKeyFromKeyRef : %v" , err )
166
+ return nil , fmt .Errorf ("error getting public key from key reference : %v" , err )
163
167
}
164
168
pkcs11Key , ok := pubKey .(* pkcs11key.Key )
165
169
if ok {
@@ -171,14 +175,14 @@ func verifyImageSignatures(ctx context.Context, key string, verifiers []Verifier
171
175
172
176
ref , err := name .ParseReference (key )
173
177
if err != nil {
174
- return nil , fmt .Errorf ("parseReference : %v" , err )
178
+ return nil , fmt .Errorf ("error parsing image reference : %v" , err )
175
179
}
176
180
177
181
metadata := & checkedMetadata {}
178
182
if contains (o .Verifies , "imageSignature" ) {
179
183
checkedSignatures , bundleVerified , err := cosign .VerifyImageSignatures (ctx , ref , co )
180
184
if err != nil {
181
- return nil , fmt .Errorf ("verifyImageSignatures : %v" , err )
185
+ return nil , fmt .Errorf ("error verifying image signatures : %v" , err )
182
186
}
183
187
184
188
if co .RekorClient != nil && ! bundleVerified {
@@ -189,9 +193,9 @@ func verifyImageSignatures(ctx context.Context, key string, verifiers []Verifier
189
193
return nil , fmt .Errorf ("no valid signatures found for %s" , key )
190
194
}
191
195
192
- metadata .ImageSignatures , err = formatSignaturePayloads (checkedSignatures )
196
+ metadata .Signatures , err = formatSignaturePayloads (checkedSignatures )
193
197
if err != nil {
194
- return nil , fmt .Errorf ("formatSignaturePayloads : %v" , err )
198
+ return nil , fmt .Errorf ("error formatting signature payload : %v" , err )
195
199
}
196
200
197
201
fmt .Println ("signature verified for: " , key )
@@ -202,7 +206,7 @@ func verifyImageSignatures(ctx context.Context, key string, verifiers []Verifier
202
206
203
207
checkedAttestations , bundleVerified , err := cosign .VerifyImageAttestations (ctx , ref , co )
204
208
if err != nil {
205
- return nil , fmt .Errorf ("verifyImageAttestations : %v" , err )
209
+ return nil , fmt .Errorf ("error verifying attestations : %v" , err )
206
210
}
207
211
if co .RekorClient != nil && ! bundleVerified {
208
212
return nil , fmt .Errorf ("no valid attestations found for: %s" , key )
@@ -213,7 +217,7 @@ func verifyImageSignatures(ctx context.Context, key string, verifiers []Verifier
213
217
return nil , fmt .Errorf ("formatAttestations: %v" , err )
214
218
}
215
219
216
- metadata .AttestationSignatures = AttestationPayloads
220
+ metadata .Attestations = AttestationPayloads
217
221
218
222
fmt .Println ("attestation verified for: " , key )
219
223
fmt .Printf ("%d number of valid attestations found for %s, found attestations: %v\n " , len (checkedAttestations ), key , checkedAttestations )
@@ -254,7 +258,7 @@ func formatAttestations(verifiedAttestations []oci.Signature) ([]in_toto.Stateme
254
258
255
259
statementRaw , err := base64 .StdEncoding .DecodeString (payload )
256
260
if err != nil {
257
- fmt .Fprintf (os .Stderr , "error decoding payload: %v" , err )
261
+ fmt .Fprintf (os .Stderr , "error decoding attestation payload: %v" , err )
258
262
}
259
263
260
264
var statement in_toto.Statement
0 commit comments