Sample code for 30+ languages & platforms
Go

Apple Keychain - List Certificates

See more Apple Keychain Examples

Iterates over the certificates in the Apple Keychain.

Chilkat Go Downloads

Go
    success := false

    certStore := chilkat.NewCertStore()

    // On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
    // The argument passed to OpenCurrentUserStore is ignored.
    success = certStore.OpenCurrentUserStore(false)
    if success == false {
        fmt.Println(certStore.LastErrorText())
        certStore.DisposeCertStore()
        return
    }

    numCerts := certStore.NumCertificates()
    fmt.Println("numCerts = ", numCerts)

    cert := chilkat.NewCert()
    i := 0
    for i < numCerts {
        certStore.GetCert(i,cert)
        fmt.Println(cert.SubjectDN())
        fmt.Println(cert.SubjectCN())
        fmt.Println(cert.SerialNumber())
        fmt.Println("----")
        i = i + 1
    }

    certStore.CloseCertStore()

    certStore.DisposeCertStore()
    cert.DisposeCert()