Java
Java
Apple Keychain - List Certificates
See more Apple Keychain Examples
Iterates over the certificates in the Apple Keychain.Chilkat Java Downloads
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
boolean success = false;
CkCertStore certStore = new CkCertStore();
// On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
// The argument passed to OpenCurrentUserStore is ignored.
success = certStore.OpenCurrentUserStore(false);
if (success == false) {
System.out.println(certStore.lastErrorText());
return;
}
int numCerts = certStore.get_NumCertificates();
System.out.println("numCerts = " + numCerts);
CkCert cert = new CkCert();
int i = 0;
while (i < numCerts) {
certStore.GetCert(i,cert);
System.out.println(cert.subjectDN());
System.out.println(cert.subjectCN());
System.out.println(cert.serialNumber());
System.out.println("----");
i = i+1;
}
certStore.CloseCertStore();
}
}