我正在使用网络代码:
import iaik.pkcs.pkcs11.Module;
import iaik.pkcs.pkcs11.Info;
public class PKCS11Test {
public static void main(String[] args) {
if (args.length == 1) {
try {
Module pkcs11Module = Module.getInstance(args[0], "C:/Temp/pkcs11wrapper.dll");
pkcs11Module.initialize(null);
Info info = pkcs11Module.getInfo();
System.out.println(info);
pkcs11Module.finalize(null);
} catch (Throwable ex) {
ex.printStackTrace();
}
} else {
printUsage();
System.exit(1);
}
}
protected static void printUsage() {
System.out.println("ModuleInfo <PKCS#11 module name>");
System.out.println("e.g.: ModuleInfo pk2priv.dll");
}
}
带参数:pkcs11wrapper.dll和VM param -Djava.library.path = C:/ Temp。
代码中的“C:/Temp/pkcs11wrapper.dll”不是必需的......
我得到的是:
java.io.IOException: The specified procedure could not be found.
at iaik.pkcs.pkcs11.wrapper.PKCS11Implementation.connect(Native Method)
at iaik.pkcs.pkcs11.wrapper.PKCS11Implementation.<init>(PKCS11Implementation.java:183)
at iaik.pkcs.pkcs11.wrapper.PKCS11Connector.connectToPKCS11Module(PKCS11Connector.java:92)
at iaik.pkcs.pkcs11.Module.getInstance(Module.java:223)
at PKCS11Test.main(PKCS11Test.java:11)
我的JRE是64位,dll也是64位(用32位版本替换它给出了关于错误的dll版本的明确错误) JRE是v1.7.0.21,iaik包装器v1.2.18。 如果我使用32位JRE和32位dll,则错误是相同的。
这里可能有什么问题?
我获得了iaikPkcs11Wrapper v1.3的源代码,当在DEBUG模式下运行时,我得到了行:PKCS11Connector.connectToPKCS11Module(String, String) line: 92
调用return new PKCS11Implementation(pkcs11ModulePath, pkcs11WrapperPath);
的地方。尽管源代码中存在PKCS11Implementation类,但调试器不希望跳转构造函数代码:
ClassNotFoundException(Throwable).<init>(String, Throwable) line: 286
ClassNotFoundException(Exception).<init>(String, Throwable) line: not available
ClassNotFoundException(ReflectiveOperationException).<init>(String, Throwable) line: not available
ClassNotFoundException.<init>(String) line: not available
URLClassLoader$1.run() line: not available
URLClassLoader$1.run() line: not available
AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]
Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available
Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader.loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available
PKCS11Connector.connectToPKCS11Module(String, String) line: 92
这些结果是在运行仅包含IAIK源和测试类的项目时实现的。
答案 0 :(得分:3)
例外
java.io.IOException: The specified procedure could not be found.
at iaik.pkcs.pkcs11.wrapper.PKCS11Implementation.connect(Native Method)
表示在DLL pk2priv.dll(或动态喜欢它的DLL)中,包装器方法无法找到要连接的预期本机函数。您使用的驱动程序和硬件是什么?