From 7a02d51a837b7d2ba1a8edaad3b048ac3bd382a4 Mon Sep 17 00:00:00 2001 From: olszomal Date: Thu, 15 Feb 2024 12:27:40 +0100 Subject: [PATCH] Print failed certificate chain retrieved from the signature --- osslsigncode.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/osslsigncode.c b/osslsigncode.c index a96df22..a78f650 100644 --- a/osslsigncode.c +++ b/osslsigncode.c @@ -1295,6 +1295,8 @@ static void print_cert(X509 *cert, int i) char *subject, *issuer, *serial; BIGNUM *serialbn; + if (!cert) + return; subject = X509_NAME_oneline(X509_get_subject_name(cert), NULL, 0); issuer = X509_NAME_oneline(X509_get_issuer_name(cert), NULL, 0); serialbn = ASN1_INTEGER_to_BN(X509_get_serialNumber(cert), NULL); @@ -1314,6 +1316,19 @@ static void print_cert(X509 *cert, int i) OPENSSL_free(serial); } +/* + * [in] certs: X509 certificate chain + * [returns] none + */ +static void print_certs_chain(STACK_OF(X509) *certs) +{ + int i; + + for (i=0; id.sign->contents->d.other->value.sequence->data, p7->d.sign->contents->d.other->value.sequence->length); } - printf("Signing Certificate Chain:\n"); + printf("Signing certificate chain verified using:\n"); /* * In the PKCS7_verify() function, the BIO *indata parameter refers to * the signed data if the content is detached from p7. @@ -1887,6 +1908,8 @@ static int verify_authenticode(FILE_FORMAT_CTX *ctx, PKCS7 *p7, time_t time, X50 printf("\nPKCS7_verify error\n"); X509_STORE_free(store); BIO_free(bio); + printf("\nFailed signing certificate chain retrieved from the signature:\n"); + print_certs_chain(p7->d.sign->cert); goto out; } X509_STORE_free(store);