Swift Requires Chilkat v10.1.2+
Swift
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 Swift Downloads
func chilkatTest() {
var success: Bool = false
let certStore = CkoCertStore()!
// The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
var readOnly: Bool = true
success = certStore.openWindowsStore(storeLocation: "CurrentUser", storeName: "AddressBook", readOnly: readOnly)
if success != true {
print("\(certStore.lastErrorText!)")
return
}
// Find the certificate for the email address:
let jsonE = CkoJsonObject()!
jsonE.updateString(jsonPath: "email", value: "joe@example.com")
let cert = CkoCert()!
success = certStore.findCert(json: jsonE, cert: cert)
if success == false {
print("\(certStore.lastErrorText!)")
return
}
print("Found certificate: \(cert.subjectDN!)")
}