(Lianja) Find Certificate by Subject CN (Common Name)
Demonstrates how to find a certificate having the specified subject CN.
Note: Requires Chilkat v10.1.2 or later.
loCertStore = createobject("CkCertStore")
// This opens the Current User certificate store on Windows,
// On MacOS and iOS it opens the default Keychain.
llReadOnly = .F.
llSuccess = loCertStore.OpenCurrentUserStore(llReadOnly)
if (llSuccess = .F.) then
? loCertStore.LastErrorText
release loCertStore
return
endif
// Find the certificate having a Subject CN = "Example ABC".
loJson = createobject("CkJsonObject")
loJson.UpdateString("CN","Example ABC")
loCert = createobject("CkCert")
llSuccess = loCertStore.FindCert(loJson,loCert)
if (llSuccess = .T.) then
// Show the full distinguished name of the certificate.
? "Found: " + loCert.SubjectDN
else
? "Not found."
endif
release loCertStore
release loJson
release loCert
|