Java
Java
Find a Certificate in the "Other People" Windows Certificate Store
See more Certificates Examples
Demonstrates how to open the "Current User --> Other People" Windows certificate store, and locates a certificate matching an email address.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();
// The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
boolean readOnly = true;
success = certStore.OpenWindowsStore("CurrentUser","AddressBook",readOnly);
if (success != true) {
System.out.println(certStore.lastErrorText());
return;
}
// Find the certificate for the email address:
CkJsonObject jsonE = new CkJsonObject();
jsonE.UpdateString("email","joe@example.com");
CkCert cert = new CkCert();
success = certStore.FindCert(jsonE,cert);
if (success == false) {
System.out.println(certStore.lastErrorText());
return;
}
System.out.println("Found certificate: " + cert.subjectDN());
}
}