问题
I'm trying to digitally sign XML documents. For that I have 2 options. There's a library for programmers created by Estonian Certifying Centre and there is a script, that runs a Java code, made by a bank. If using the official (Certifying Centre) library then everything works like a charm with a little bit of tweaking, but when it comes to the bank script then it goes berserk resulting in errors:
java.io.IOException: %1 is not a valid Win32 application.
esteid-pkcs11
at iaik.pkcs.pkcs11.wrapper.PKCS11Implementation.connect(Native Method)
at iaik.pkcs.pkcs11.wrapper.PKCS11Implementation.<init>(PKCS11Implementation.java:166)
at iaik.pkcs.pkcs11.wrapper.PKCS11Connector.connectToPKCS11Module(PKCS11Connector.java:75)
at iaik.pkcs.pkcs11.Module.getInstance(Module.java:202)
at client.smartcard.SmartcardHelper.initializePKCS11Module(SmartcardHelper.java:46)
at client.smartcard.SmartcardHelper.initialize(SmartcardHelper.java:29)
at client.smartcard.SmartcardHelper.initialize(SmartcardHelper.java:21)
at client.Signer.main(Signer.java:36)
10:03:31 ERROR - Signing failed: PKCS11 initialization failed
java.lang.RuntimeException: PKCS11 initialization failed
at client.smartcard.SmartcardHelper.initializePKCS11Module(SmartcardHelper.java:52)
at client.smartcard.SmartcardHelper.initialize(SmartcardHelper.java:29)
at client.smartcard.SmartcardHelper.initialize(SmartcardHelper.java:21)
at client.Signer.main(Signer.java:36)
Caused by: java.io.IOException: %1 is not a valid Win32 application.
esteid-pkcs11
at iaik.pkcs.pkcs11.wrapper.PKCS11Implementation.connect(Native Method)
at iaik.pkcs.pkcs11.wrapper.PKCS11Implementation.<init>(PKCS11Implementation.java:166)
at iaik.pkcs.pkcs11.wrapper.PKCS11Connector.connectToPKCS11Module(PKCS11Connector.java:75)
at iaik.pkcs.pkcs11.Module.getInstance(Module.java:202)
at client.smartcard.SmartcardHelper.initializePKCS11Module(SmartcardHelper.java:46)
... 3 more
Esteid-pkcs11
file is a country-specific dll-file. I have read lot of responses on google to problems that resulted with the same error, but none of the replies seem to do the trick. I have installed JDK(64-bit) and JRE(32-bit). I thought that maybe the .dll
file I tried opening is 32-bit and so I changed JAVA_HOME
path to point to 32-bit JRE, but then it said something like
cannot load IA 32-bit .dll on a amd 64-bit platform.
So I figured that it isn't a problem with bits. After messing around with environment variables for few hours I figured that it might be a problem with the bank-made script. Can that be the case? If not what else is there that can cause this error?
Edit: Apparently I tried using C-library for signing and it works, but when using Java-library, it gives me an error.
java.io.IOException: %1 is not a valid Win32 application.
opensc-pkcs11.dll
I am 100% sure that opensc-pkcs11.dll is a 64-bit dll, but I was wondering if maybe console don't have access to system32 folder. Can that be the case?
回答1:
The error
Caused by: java.io.IOException: %1 is not a valid Win32 application.
is what I got when I tried to use a 32-bit PKCS#11 DLL, via the Sun PKCS#11 Provider, from a 64-bit Java environment.
When I switched to a 64-bit PKCS#11 DLL the error stopped occurring.
I think your 'esteid-pkcs11' file is a 32-bit DLL.
回答2:
Maybe opensc-pkcs11.dll contains references to other dlls on the same directory.
I had a similar error with Gemalto (Safenet) crpytoki.dll. The solution was to put the directory containing cryptoki.dll into Windows PATH.
来源:https://stackoverflow.com/questions/17207967/java-io-ioexception-1-is-not-a-valid-win32-application