Sample code for 30+ languages & platforms
Delphi DLL

Windows Certificate Stores - Find Certificate by Common Name

See more Certificates Examples

Searches the Windows certificate stores for a certificate that matches the specified common name (CN).

Note: This example requires Chilkat v10.0.0 or greater.

Chilkat Delphi DLL Downloads

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

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
cert: HCkCert;

begin
success := False;

cert := CkCert_Create();
success := CkCert_LoadByCommonName(cert,'Chilkat Software, Inc.');
if (success = False) then
  begin
    Memo1.Lines.Add(CkCert__lastErrorText(cert));
    Exit;
  end;

Memo1.Lines.Add(CkCert__subjectDN(cert));
Memo1.Lines.Add('Success.');

CkCert_Dispose(cert);

end;