@@ -171,15 +171,30 @@ func (c *VerifyCommand) Exec(ctx context.Context, images []string) (err error) {
171
171
}
172
172
}
173
173
if keylessVerification (c .KeyRef , c .Sk ) {
174
- // This performs an online fetch of the Fulcio roots. This is needed
175
- // for verifying keyless certificates (both online and offline).
176
- co .RootCerts , err = fulcio .GetRoots ()
177
- if err != nil {
178
- return fmt .Errorf ("getting Fulcio roots: %w" , err )
179
- }
180
- co .IntermediateCerts , err = fulcio .GetIntermediates ()
181
- if err != nil {
182
- return fmt .Errorf ("getting Fulcio intermediates: %w" , err )
174
+ if c .CertChain != "" {
175
+ chain , err := loadCertChainFromFileOrURL (c .CertChain )
176
+ if err != nil {
177
+ return err
178
+ }
179
+ co .RootCerts = x509 .NewCertPool ()
180
+ co .RootCerts .AddCert (chain [len (chain )- 1 ])
181
+ if len (chain ) > 1 {
182
+ co .IntermediateCerts = x509 .NewCertPool ()
183
+ for _ , cert := range chain [:len (chain )- 1 ] {
184
+ co .IntermediateCerts .AddCert (cert )
185
+ }
186
+ }
187
+ } else {
188
+ // This performs an online fetch of the Fulcio roots. This is needed
189
+ // for verifying keyless certificates (both online and offline).
190
+ co .RootCerts , err = fulcio .GetRoots ()
191
+ if err != nil {
192
+ return fmt .Errorf ("getting Fulcio roots: %w" , err )
193
+ }
194
+ co .IntermediateCerts , err = fulcio .GetIntermediates ()
195
+ if err != nil {
196
+ return fmt .Errorf ("getting Fulcio intermediates: %w" , err )
197
+ }
183
198
}
184
199
}
185
200
keyRef := c .KeyRef
0 commit comments