Jump to content
KodeZwerg

Read out signed executable certificate possible?

Recommended Posts

Good day,

 

I would like to have ability in my project to show certificate details of signed executables. (From other executables)

 

Is that possible with Delphi?

 

Would love to get hints 'how-to'!

 

 

//edit

For now I have ability to get raw data thats appended to executables (overlay data) by simply check PE header for filesize and compare with real physical filesize.

Edited by KodeZwerg

Share this post


Link to post

Maybe you can check if file is signed with this:

 

uses Winapi.ImageHlp;

function IsFileDigitallySigned(const FileName: string): Boolean;
var
  FileHandle: THandle;
  CertHeader: TWinCertificate;
begin
  Result := False;
  FileHandle := CreateFile(PChar(FileName), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
  if FileHandle <> INVALID_HANDLE_VALUE then
    try
      FillChar(CertHeader, SizeOf(CertHeader), 0);
      Result := ImageGetCertificateHeader(FileHandle, 0, CertHeader);
    finally
      CloseHandle(FileHandle);
    end;
end;

 

Edited by davornik

Share this post


Link to post

Beware TWinCertificate is only declared in Delphi 12, perhaps ImageHlp as well. 

 

But I'll look at those functions to allow verifying the signing chain using OpenSSL instead of the slow capicom.dll COM object used by my component at the moment, but not looked at the component for several years. 

 

Angus

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×