(.NET Core C#) Apple Keychain - List Certs on Smartcards and USB Tokens
Iterates over the certificatse on connected smartcards and USB tokens via the Apple Keychain.
Note: This example requires Chilkat v10.0.0 or greater.
Chilkat.CertStore certStore = new Chilkat.CertStore();
// On MacOS and iOS, the OpenSmartcard method opens the Keychain.
// The argument passed to OpenSmartcard is ignored.
bool success = certStore.OpenSmartcard("");
if (success == false) {
Debug.WriteLine(certStore.LastErrorText);
return;
}
int numCerts = certStore.NumCertificates;
Debug.WriteLine("numCerts = " + Convert.ToString(numCerts));
int i = 0;
while (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.
Chilkat.Cert cert = certStore.GetCertificate(i);
Debug.WriteLine(cert.SubjectDN);
Debug.WriteLine("has private key: " + Convert.ToString(cert.HasPrivateKey()));
i = i + 1;
}
certStore.CloseCertStore();
|