Sample code for 30+ languages & platforms
Delphi ActiveX

Find a Certificate in the "Other People" Windows Certificate Store

See more Certificates Examples

Demonstrates how to open the "Current User --> Other People" Windows certificate store, and locates a certificate matching an email address.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
certStore: TChilkatCertStore;
readOnly: Integer;
jsonE: TChilkatJsonObject;
cert: TChilkatCert;

begin
success := 0;

certStore := TChilkatCertStore.Create(Self);

// The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
readOnly := 1;
success := certStore.OpenWindowsStore('CurrentUser','AddressBook',readOnly);
if (success <> 1) then
  begin
    Memo1.Lines.Add(certStore.LastErrorText);
    Exit;
  end;

// Find the certificate for the email address:
jsonE := TChilkatJsonObject.Create(Self);
jsonE.UpdateString('email','joe@example.com');

cert := TChilkatCert.Create(Self);
success := certStore.FindCert(jsonE.ControlInterface,cert.ControlInterface);
if (success = 0) then
  begin
    Memo1.Lines.Add(certStore.LastErrorText);
    Exit;
  end;

Memo1.Lines.Add('Found certificate: ' + cert.SubjectDN);
end;