Skip to content

Commit 6390ae2

Browse files
olszomalmtrojnar
authored andcommitted
Add keyUsage digitalSignature validation for signer certificate
1 parent a472d7f commit 6390ae2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

osslsigncode.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,9 +2513,17 @@ static int verify_authenticode(FILE_FORMAT_CTX *ctx, PKCS7 *p7, time_t time, X50
25132513
if (!crlok)
25142514
goto out;
25152515
}
2516-
/* check extended key usage flag XKU_CODE_SIGN */
2516+
/*
2517+
* Verify that:
2518+
* - extendedKeyUsage, if present, permits codeSigning (RFC 5280 section 4.2.1.12)
2519+
* - keyUsage, if present, permits digitalSignature (RFC 5280 section 4.2.1.3)
2520+
*/
25172521
if (!(X509_get_extended_key_usage(signer) & XKU_CODE_SIGN)) {
2518-
fprintf(stderr, "Unsupported Signer's certificate purpose XKU_CODE_SIGN\n");
2522+
fprintf(stderr, "Signer certificate rejected: extendedKeyUsage does not permit codeSigning\n");
2523+
goto out;
2524+
}
2525+
if (!(X509_get_key_usage(signer) & X509v3_KU_DIGITAL_SIGNATURE)) {
2526+
fprintf(stderr, "Signer certificate rejected: keyUsage does not permit digitalSignature\n");
25192527
goto out;
25202528
}
25212529

0 commit comments

Comments
 (0)