So here's what I'm trying to do. I have a hardware token with some certs on it and I'm writing a Java application to try and access those certs. I have used the SunPKCS11 library in jre6 for a windows 32 bit machine. This is a small sample of how I access the certs:
String configName = "pkcs.cnf"
String PIN = "123456";
Provider p = new sun.security.pkcs11.SunPKCS11(configName);
Security.addProvider(p);
KeyStore keyStore = KeyStore.getInstance("PKCS11");
char[] pin = PIN.toCharArray();
keyStore.load(null, pin);
It works great, I'm able to get the certs and everything. Now I'm trying to do the same on a 64 bit machine. However I am trying to use the 64 bit jre6 library and that is missing the SunPKCS11 jar file (located in {java.home}/lib/ext
. Because of that I cannot create a SunPKCS11 object. My question to you is, what do I do now? How can I access the certs on a token using 64 bit java libraries? Has someone written a 64 bit wrapper for such a task?
PKCS11 Support was not implemented because there was no way to test that library (somehow, whatever).
This has changed in Java 8, though. Since J8b49 a 64 bit Version is included. See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6880559
Assuming your {java.home} points to jre6, sunpkcs11.jar is in the {java.home}/lib/ext; If your {java.home} points to jdk1.6, sunpkcs11.jar is in the {java.home}/jre/lib/ext; I've tested it against the newly installed jdk and jre. Please verify your installation.
EDITED (summarising the comments)
In java 64-bit version pkcs11 is not available.
来源:https://stackoverflow.com/questions/8056818/accessing-hardware-pkcs11-token-on-a-64-bit-machine