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

List Certificates in the Current User Certificate Store (Windows Only)

See more Certificates Examples

This is a Windows-only example to list the certificates in the current-user certificate store (located in the Windows Registry).

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    //  This is a Windows-only example because it lists the certificates
    //  stored in the Windows Current User Certificate Store located in the
    //  Windows Registry.

    let certStore = CkoCertStore()!

    var readOnly: Bool = true
    success = certStore.openCurrentUserStore(readOnly: readOnly)
    if success == false {
        print("\(certStore.lastErrorText!)")
        return
    }

    let cert = CkoCert()!
    var numCerts: Int = certStore.numCertificates.intValue
    var i: Int = 0
    while i < numCerts {
        certStore.getCert(index: i, cert: cert)
        print("DN = \(cert.subjectDN!)")
        print("Email = \(cert.subjectE!)")
        i = i + 1
    }


}