Go
Go
Apple Keychain - List Certs on Smartcards and USB Tokens
See more Apple Keychain Examples
Iterates over the certificatse on connected smartcards and USB tokens via the Apple Keychain.Chilkat Go Downloads
success := false
certStore := chilkat.NewCertStore()
// On MacOS and iOS, the OpenSmartcard method opens the Keychain.
// The argument passed to OpenSmartcard is ignored.
success = certStore.OpenSmartcard("")
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 {
// Note: Chilkat also gets the associated private key if it exists.
// You can simply use the cert in other places in Chilkat where a cert w/ private key is required.
certStore.GetCert(i,cert)
fmt.Println(cert.SubjectDN())
fmt.Println(cert.SubjectCN())
fmt.Println(cert.SerialNumber())
if cert.IsRsa() == true {
fmt.Println("key type is RSA")
}
if cert.IsEcdsa() == true {
fmt.Println("key type is ECDSA")
}
fmt.Println("has private key: ", *cert.HasPrivateKey())
fmt.Println("----")
i = i + 1
}
certStore.CloseCertStore()
certStore.DisposeCertStore()
cert.DisposeCert()