Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6391777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:43:54+00:00 2026-05-25T03:43:54+00:00

I want to validate certificates of signed executable images (by validation, I mean to

  • 0

I want to validate certificates of signed executable images (by validation, I mean to tell if the signature comes from MS/Adobe/Oracle etc.). Does windows provides api for this task? How should I do that, no idea. Any help would be appreciated.
I’m using Windows and C++. I want to validate native executable images, not .NET assemblies or Java jar files.

UPDATE


Ok, I’ll try to describe what I want shortly.

1) Validate PE certificate. Is the signature valid or not. It should work when signature is embedded in PE and when the signature is in security catalog. (I found this on sysinternals forum and works fine, so I don’t need this one anymore).

2) Tell who’s the signer/publisher of the file. I know it can be achieved through CryptQueryObject (I found a working example, though it doesn’t work with security catalogs), but don’t know how to use it with security catalog files.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:43:54+00:00Added an answer on May 25, 2026 at 3:43 am

    There are many API and approaches how you can get and verify the signature of the executable and how you can get other additional information which you need. The problem is which level you choose (high level like WinVerifyTrust)

    The easiest first API which can be used to get cryptography context from the CAT or EXE file is CryptQueryObject function. The code example from the KB323809 could get you the main idea how to decode information what you need. the main difference if you work with CAT files is that you should modify the some parameters of CryptQueryObject. I recommend you just to use CERT_QUERY_CONTENT_FLAG_ALL and CERT_QUERY_FORMAT_FLAG_ALL and CryptQueryObject will do all what you needs internally:

    BOOL bIsSuccess;
    DWORD dwEncoding, dwContentType, dwFormatType;
    HCERTSTORE hStore = NULL;
    HCRYPTMSG hMsg = NULL;
    PVOID pvContext = NULL;
    
    // fill szFileName
    ...
    
    // Get message handle and store handle from the signed file.
    bIsSuccess = CryptQueryObject (CERT_QUERY_OBJECT_FILE,
                                   szFileName,
                                   CERT_QUERY_CONTENT_FLAG_ALL,
                                   CERT_QUERY_FORMAT_FLAG_ALL,
                                   0,
                                   &dwEncoding,
                                   &dwContentType,
                                   &dwFormatType,
                                   &hStore,
                                   &hMsg,
                                   &pvContext);
    

    The value dwContentType set by the CryptQueryObject will get you the base information about the type of the file szFileName. The pvContext will be PCCERT_CONTEXT for the most cases which you need, but it can be also PCCRL_CONTEXT or PCCTL_CONTEXT if you use .ctl or .crl file as the input. You will receive the hStore filled with all certificates from the file szFileName. So with respect of pvContext and hStore you can examine the file contain with CryptoAPI. If you do prefer
    low-level massages API you can use hMsg which will be additionally set in case of some dwContentType (at least for for CERT_QUERY_CONTENT_PKCS7_SIGNED, CERT_QUERY_CONTENT_PKCS7_UNSIGNED, CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED).

    To verify the signature of the file I would recommend you to use CertGetCertificateChain and CertVerifyCertificateChainPolicy to verify not only that the certificate is valid in general, but that it (or all its parents) is valid for authenticode (szOID_PKIX_KP_CODE_SIGNING). CertGetCertificateChain can be used for different revocation scenarios. You should do two separate calls with CERT_CHAIN_POLICY_AUTHENTICODE and CERT_CHAIN_POLICY_AUTHENTICODE_TS to verify that both Authenticode chain policy and Authenticode Time Stamp chain policy are valid.

    UPDATED: I reread your current question (the Updated part). Your current problem is how to get the signer/publisher of the file. So I answer only on the question.

    If you use the code from sysinternal for the signature verification you should just search for the line

    if ( !CryptCATCatalogInfoFromContext(CatalogContext, &InfoStruct, 0) )
    

    The statement sill set the fields of the InfoStruct in case that that file is system windows file which signature is verified with respect of some .cat file. The field InfoStruct.wszCatalogFile will get you the name of the .cat file.

    For example on my Windows 7 if I try to verify the digital signature of the C:\Windows\explorer.exe file, the .cat where its hash could be found is C:\Windows\system32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\Package_1_for_KB2515325~31bf3856ad364e35~amd64~~6.1.1.0.cat.

    If you would use code from KB323809 with described above parameters of CryptQueryObject you will decode the SPC_SP_OPUS_INFO_OBJID (“1.3.6.1.4.1.311.2.1.12”) attribute of the C:\Windows\system32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\Package_1_for_KB2515325~31bf3856ad364e35~amd64~~6.1.1.0.cat (see the function GetProgAndPublisherInfo) and you will know

    pwszProgramName: "Windows Express Security Catalogs"
    pPublisherInfo: NULL
    pMoreInfo->dwLinkChoice: SPC_URL_LINK_CHOICE
    pMoreInfo->pwszUrl "http://www.microsoft.com"
    

    So no special publisher information are included for the file. If you examine the signer of the the catalog you will find out that:

    The signer of the .cat file: "Microsoft Windows"
    The signer signed it with the certificate:
        Serial Number: 0x6115230F00000000000A
        Issuer Name: Microsoft Windows Verification PCA
        Full Issuer Name:
            CN = Microsoft Windows Verification PCA
            O = Microsoft Corporation
            L = Redmond
            S = Washington
            C = US
        Subject Name: Microsoft Windows
        Full Subject Name:
            CN = Microsoft Windows
            OU = MOPR
            O = Microsoft Corporation
            L = Redmond
            S = Washington
            C = US
    The Date of TimeStamp : 28.02.2011 21:16:36
    TimeStamp Certificate: 
        Serial Number: 0x6103DCF600000000000C
        Issuer Name: Microsoft Time-Stamp PCA
        Subject Name: Microsoft Time-Stamp Service
    

    So you should use just the signer of the .cat file, because there are no other signer of explorer.exe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to validate array of beans using JSR 303 Validation. Like spec says,
I want to validate my form using server side validation only. However, if the
I want to validate fields with Cakephp model validation, without saving the data, for
I want to validate string containing only numbers. Easy validation? I added RegularExpressionValidator, with
I want to validate the value a user enters in a text box, so
I want to validate a set of credentials against the domain controller. e.g.: Username:
I want to validate an XML file against an XML Schema file. It is
I want to validate a condition before doing the next step, but only raise
I want to validate below data using regex and python. Below is the dump
I want to validate a registration form that accepts an email address in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.