Delphi 7 access Windows X509 Certificate Store

2019-08-02 09:37发布

问题:

My question is pretty simple: is there a simple way to access Windows X509 Certificate Store using Delphi 7?

Before asking this question I have googled, but have not found any useful info.

回答1:

the easiest way is to use capicom, hitting the win capi api directly is painful.

once you've registered the com object and created your typelib unit from it..

open the appropriate store, and from there use the certificates() method..

  var
    store: TStore;
    certificates: ICertificates;
    certificate: ICertificate2

  store := TStore.Create(nil);
  store.Open(CAPICOM_CURRENT_USER_STORE, 'My', CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED or CAPICOM_STORE_OPEN_INCLUDE_ARCHIVED or CAPICOM_STORE_OPEN_EXISTING_ONLY);

  certificates := store.Certificates;
  for i := 1 to certificates.count do
  begin
    certificate := IInterface(certificates.Item[i]) as ICertificate2;
    // work with the cert
  end;

  store.close();
  store.Free;

capicom reference is at http://msdn.microsoft.com/en-us/library/ms995332.aspx

if you're ok with spending money, i've heard good things about PKIBlackbox from eldos.



回答2:

Isn't that what you are looking for? Cryptography Reference

Or do you search an API Wrapper?



回答3:

There are a complex library fom ELDOS that add complete support for work with X509 Certificates and more; Read complete description here:
components for Public Key Infrastructure (PKI) support

See the Reference for the class ElX509CertificateClass here.

Regards.