.NET Core C#
.NET Core C#
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 .NET Core C# Downloads
bool success = false;
Chilkat.CertStore certStore = new Chilkat.CertStore();
// On MacOS and iOS, the OpenSmartcard method opens the Keychain.
// The argument passed to OpenSmartcard is ignored.
success = certStore.OpenSmartcard("");
if (success == false) {
Debug.WriteLine(certStore.LastErrorText);
return;
}
int numCerts = certStore.NumCertificates;
Debug.WriteLine("numCerts = " + Convert.ToString(numCerts));
Chilkat.Cert cert = new Chilkat.Cert();
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.
certStore.GetCert(i,cert);
Debug.WriteLine(cert.SubjectDN);
Debug.WriteLine(cert.SubjectCN);
Debug.WriteLine(cert.SerialNumber);
if (cert.IsRsa() == true) {
Debug.WriteLine("key type is RSA");
}
if (cert.IsEcdsa() == true) {
Debug.WriteLine("key type is ECDSA");
}
Debug.WriteLine("has private key: " + Convert.ToString(cert.HasPrivateKey()));
Debug.WriteLine("----");
i = i + 1;
}
certStore.CloseCertStore();