Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v10.1.2+

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oCertStore
LOCAL nReadOnly
LOCAL oJsonE
LOCAL oCert

nSuccess := 0

oCertStore := CreateObject("Chilkat.CertStore")

//  The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
nReadOnly := 1
nSuccess := oCertStore:OpenWindowsStore("CurrentUser", "AddressBook", nReadOnly)
IF (nSuccess != 1)
    ? oCertStore:LastErrorText
    oCertStore:destroy()
    RETURN
ENDIF

//  Find the certificate for the email address:
oJsonE := CreateObject("Chilkat.JsonObject")
oJsonE:UpdateString("email", "joe@example.com")

oCert := CreateObject("Chilkat.Cert")
nSuccess := oCertStore:FindCert(oJsonE, oCert)
IF (nSuccess == 0)
    ? oCertStore:LastErrorText
    oCertStore:destroy()
    oJsonE:destroy()
    oCert:destroy()
    RETURN
ENDIF

? "Found certificate: " + oCert:SubjectDN

oCertStore:destroy()
oJsonE:destroy()
oCert:destroy()