I'm trying to use a custom security provider with JDK 11's jarsigner
application. I'm using the following command:
jarsigner -verbose -keystore C:\foo\bar\mykeystore -storetype Luna -tsa http://timestamp.digicert.com C:\foo\bar\sample.jar "mykeyalias" -provider com.safenetinc.luna.provider.LunaProvider
However, I receive the following error output:
jarsigner error: java.lang.Exception: Provider "com.safenetinc.luna.provider.LunaProvider" not found
I found Using custom PKCS11 provider with jarsigner and tried to use the -J-cp
option but then I get the error:
jarsigner error: java.lang.RuntimeException: unable to instantiate keystore class: LUNA not found
Using the suggested -J-Djava.ext.dirs=C:\foo\bar\LunaProvider.jar
does not work either, it fails with:
-Djava.ext.dirs=C:\foo\bar\LunaProvider.jar is not supported. Use -classpath instead.
The option -classpath does not exist, but it is probably referencing -cp, which I already tried (see above).
How to do that properly?
Note: keytool is also part of the JRE, I could fix the JRE by 1) putting the JAR and the DLL of Luna in the \lib\ext directory and adjust the java.security file by adding the provider there. Unfortunately, jarsigner is only part of the JDK and I don't find a \lib\ext folder in the JDK neither do I find a java.security file.