@@ -71,7 +71,7 @@ func verifyTopologySignature(cfg *config.Config) error {
71
71
// verify the AS certificate chain (but not the payload signature) back to the TRCs of the ISD follows the
72
72
// SCION CP PKI rules about cert type, key usage:
73
73
if stdoutStderr , err := spkiCertVerify (ctx , sortedTRCsPaths , asCertChainPath ); err != nil {
74
- return fmt .Errorf ("unable to validate certificate chain: %s %w " , stdoutStderr , err )
74
+ return fmt .Errorf ("unable to validate certificate chain: %w: scion-pki output: %s " , err , stdoutStderr )
75
75
}
76
76
77
77
var unvalidatedTopologyPath string
@@ -149,13 +149,15 @@ func verifyWithRootBundle(ctx context.Context,
149
149
_ , trcFileName := filepath .Split (trustAnchorTRC )
150
150
rootCertsBundlePath := filepath .Join (verifyPath , trcFileName + ".certs.pem" )
151
151
// extract TRC certificates:
152
- if err = spkiTRCExtractCerts (ctx , trustAnchorTRC , rootCertsBundlePath ); err != nil {
153
- return fmt .Errorf ("unable to extract root certificates from TRC %s: %w" ,
154
- trustAnchorTRC , err )
152
+ var stdoutStderr []byte
153
+ if stdoutStderr , err = spkiTRCExtractCerts (ctx , trustAnchorTRC , rootCertsBundlePath ); err != nil {
154
+ return fmt .Errorf ("unable to extract root certificates from TRC %s: %w: scion-pki output: %s" ,
155
+ trustAnchorTRC , err , stdoutStderr )
155
156
}
156
157
// verify the signature and certificate chain back to a root certs bundle, write out the payload:
157
- if err = cmsVerifyOutput (ctx , signedTopology , rootCertsBundlePath , unvalidatedTopologyPath ); err != nil {
158
- return fmt .Errorf ("verifying and extracting signed payload failed: %w" , err )
158
+ if stdoutStderr , err = cmsVerifyOutput (ctx , signedTopology , rootCertsBundlePath , unvalidatedTopologyPath ); err != nil {
159
+ return fmt .Errorf ("verifying and extracting signed payload failed: %w: Verification output: %s" ,
160
+ err , stdoutStderr )
159
161
}
160
162
return
161
163
}
@@ -167,17 +169,19 @@ func extractSignerInfo(ctx context.Context, signedTopology, verifyPath string) (
167
169
168
170
detachedSignaturePath := filepath .Join (verifyPath , "detached_signature.p7s" )
169
171
// detach signature for further validation:
170
- err = smimePk7out (ctx , signedTopology , detachedSignaturePath )
172
+ var stdoutStderr []byte
173
+ stdoutStderr , err = smimePk7out (ctx , signedTopology , detachedSignaturePath )
171
174
if err != nil {
172
- err = fmt .Errorf ("unable to detach signature: %w" , err )
175
+ err = fmt .Errorf ("unable to detach signature: %w: Verification output: %s " , err , stdoutStderr )
173
176
return
174
177
}
175
178
176
179
asCertHumanChain := filepath .Join (verifyPath , "as_cert_chain.human.pem" )
177
180
// collect included certificates from detached signature:
178
- err = pkcs7Certs (ctx , detachedSignaturePath , asCertHumanChain )
181
+ stdoutStderr , err = pkcs7Certs (ctx , detachedSignaturePath , asCertHumanChain )
179
182
if err != nil {
180
- err = fmt .Errorf ("unable to gather included certificates from signature: %w" , err )
183
+ err = fmt .Errorf ("unable to gather included certificates from signature: %w: Verification output: %s" ,
184
+ err , stdoutStderr )
181
185
return
182
186
}
183
187
@@ -256,9 +260,10 @@ func verifyTRCUpdateChain(outputPath, candidateTRCPath string, strict bool) erro
256
260
}
257
261
trcUpdateChainPaths := sortTRCsFiles (trcs ).Paths ()
258
262
trcUpdateChainPaths = append (trcUpdateChainPaths , candidateTRCPath )
259
- err = spkiTRCVerify (ctx , trcUpdateChainPaths [0 ], trcUpdateChainPaths [1 :])
263
+ var stdoutStderr []byte
264
+ stdoutStderr , err = spkiTRCVerify (ctx , trcUpdateChainPaths [0 ], trcUpdateChainPaths [1 :])
260
265
if err != nil {
261
- return fmt .Errorf ("validating TRC update chain failed: %w" , err )
266
+ return fmt .Errorf ("validating TRC update chain failed: %w: scion-pki output: %s " , err , stdoutStderr )
262
267
}
263
268
return nil
264
269
}
0 commit comments