I'm trying to load the Firefox PKCS11 provider (softokn3.dll), but I always get the following error:
Exception in thread "main" java.security.ProviderException: Initialization failed
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:340)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:86)
at javapkcs11test.Main.main(Main.java:24)
Caused by: java.io.IOException: The specified module could not be found.
C:\Program Files\Mozilla Firefox\softokn3.dll
at sun.security.pkcs11.wrapper.PKCS11.connect(Native Method)
at sun.security.pkcs11.wrapper.PKCS11.<init>(PKCS11.java:141)
at sun.security.pkcs11.wrapper.PKCS11.getInstance(PKCS11.java:154)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:281)
... 2 more
I've already read this thread [http://forums.sun.com/thread.jspa?threadID=5298971] which handles the same problem, but there was no solution provided that helped me.
My code is the following:
String configName = "c:/pkcs11.config";
Provider p = new sun.security.pkcs11.SunPKCS11(configName);
Security.addProvider(p);
and my pkcs11.config looks like this:
name=NSSSoftToken
slot=2
#nssLibraryDirectory = C:\\Program Files\\Mozilla Firefox\\
#nssSecmodDirectory = "C:\\Documents and Settings\\sdm\\Application Data\\Mozilla\\Firefox\\Profiles\\tjx04kze.default"
#nssModule = fips
library=C:\Program Files\Mozilla Firefox\softokn3.dll
nssArgs="configDir='C:\\Documents and Settings\\sdm\\Application Data\\Mozilla\\Firefox\\Profiles\\tjx04kze.default' certPrefix='' keyPrefix='' secmod='secmod.db' flags=readOnly"
As you can see, I commented out a few lines I tried before but that also didn't work, I tried those after reading [http://java.sun.com/javase/6/docs/technotes/guides/security/p11guide.html#NSS]
Can anyone tell me what the problem is? And it's not that it can't find the DLL file, because when i type a wrong path on purpose it gives me another error: "file doesn't exist".
I really need to get this to work, because the eventual goal is to get it to work in C++, but as i'm not very familiar with C++, I first decided to try and make it work in Java, but even that doesn't work.
Thanks in advance to anyone who wants to help me!