If you are on Java 6, you can use the MSCAPI keystore to read it. Just open your keystore like this,
KeyStore ks = KeyStore.getInstance("Windows-MY", "SunMSCAPI");
ks.load(null, null);
java.util.Enumeration en = ks.aliases();
while (en.hasMoreElements()) {
String aliasKey = (String) en.nextElement();
Certificate[] chain = ks.getCertificateChain(aliasKey);
X509Certificate x509 = ((X509Certificate) chain[0]);
boolean keyUsage[] = x509.getKeyUsage();
//keyUsage[0] -> digitalSignature
//keyUsage[1] -> nonRepudiation
//keyUsage[2] -> keyEncipherment
//keyUsage[3] -> dataEncipherment
//keyUsage[4] -> keyAgreement
//keyUsage[5] -> keyCertSign
//keyUsage[6] -> cRLSign
//keyUsage[7] -> encipherOnly
//keyUsage[8] -> decipherOnly
}
To load windows root certificates simple replace the first line (highlighted) with this,
KeyStore ks = KeyStore.getInstance("Windows-MY", "Windows-ROOT");
To know more about the subject please read this
Thanks for posting the whole procedure on how to load windows certificate store. You have nicely explained each step. I will try to implement the same by following this article.
ReplyDeletedigital signature Adobe Acrobat