Sample code for 30+ languages & platforms
.NET Core C#

Apple Keychain - List Certificates

See more Apple Keychain Examples

Iterates over the certificates in the Apple Keychain.

Chilkat .NET Core C# Downloads

.NET Core C#
bool success = false;

Chilkat.CertStore certStore = new Chilkat.CertStore();

// On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
// The argument passed to OpenCurrentUserStore is ignored.
success = certStore.OpenCurrentUserStore(false);
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) {
    certStore.GetCert(i,cert);
    Debug.WriteLine(cert.SubjectDN);
    Debug.WriteLine(cert.SubjectCN);
    Debug.WriteLine(cert.SerialNumber);
    Debug.WriteLine("----");
    i = i + 1;
}

certStore.CloseCertStore();