Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalAccessError with maven plugin and SafeNetEToken #238

Open
InsideTheo opened this issue Sep 5, 2024 · 3 comments
Open

IllegalAccessError with maven plugin and SafeNetEToken #238

InsideTheo opened this issue Sep 5, 2024 · 3 comments

Comments

@InsideTheo
Copy link

Hi everyone,

Using the maven plugin in a Java 17 Project to sign an executable with a SafeNet token yields the following error:

[ERROR] Failed to execute goal net.jsign:jsign-maven-plugin:6.0:sign (default) on project direct-connect-client: Execution default of goal net.jsign:jsign-maven-plugin:6.0:sign failed: An API incompatibility was encountered while executing net.jsign:jsign-maven-plugin:6.0:sign: java.lang.IllegalAccessError: class net.jsign.SafeNetEToken (in unnamed module @0x550635c6) cannot access class sun.security.pkcs11.wrapper.PKCS11 (in module jdk.crypto.cryptoki) because module jdk.crypto.cryptoki does not export sun.security.pkcs11.wrapper to unnamed module @0x550635c6

Using the command line tool works just fine:
jsign --storetype ETOKEN --storepass ... -t http://timestamp.sectigo.com ...exe

I suspect it has to do with the Java version, as the sun packages imported in SafeNetEToken become unavailable in java versions 9+.

@InsideTheo
Copy link
Author

I was able to solve it by adding this to my maven options, as suggested by a different GitHub Issue (I think only the first two are needed, but could be wrong):
--add-exports jdk.crypto.cryptoki/sun.security.pkcs11=ALL-UNNAMED
--add-exports jdk.crypto.cryptoki/sun.security.pkcs11.wrapper=ALL-UNNAMED
--add-opens java.base/java.security=ALL-UNNAMED
--add-exports java.base/sun.security.action=ALL-UNNAMED
--add-exports java.base/sun.security.rsa=ALL-UNNAMED
--add-opens java.base/sun.security.util=ALL-UNNAMED

@ebourg
Copy link
Owner

ebourg commented Sep 5, 2024

Reopening, I have to document this.

@ebourg ebourg reopened this Sep 5, 2024
@krasa
Copy link

krasa commented Dec 17, 2024

Works fine with my gradle.properties at project root:

org.gradle.jvmargs=--add-exports jdk.crypto.cryptoki/sun.security.pkcs11.wrapper=ALL-UNNAMED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@ebourg @krasa @InsideTheo and others