Java Requires Chilkat v10.1.2+
Chilkat2 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.chilkat2.Cert;
import com.chilkatsoft.chilkat2.CertStore;
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.JsonObject;
public class ChilkatExample {
public static void main(String[] args) {
CertStore certStore = new CertStore();
// The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
boolean readOnly = true;
try {
certStore.openWindowsStore("CurrentUser", "AddressBook", readOnly);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
// Find the certificate for the email address:
JsonObject jsonE = new JsonObject();
jsonE.updateString("email", "joe@example.com");
Cert cert = new Cert();
try {
certStore.findCert(jsonE, cert);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
System.out.println("Found certificate: " + cert.getSubjectDN());
}
}