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

Errore Jwt-generator #13

Open
gdelgiovine opened this issue Mar 20, 2024 · 1 comment
Open

Errore Jwt-generator #13

gdelgiovine opened this issue Mar 20, 2024 · 1 comment

Comments

@gdelgiovine
Copy link

Buongiorno, stavo cercando di usare il tool per la generazione dei token JWT. Ottengo questo errore quando provo a generare i token usando gli esempi
Error while extracting key by alias from p12: java.io.IOException: error constructing MAC: java.lang.SecurityException: JCE cannot authenticate the provider BC
at org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi.engineLoad(Unknown Source)
at org.bouncycastle.jcajce.provider.keystore.util.AdaptingKeyStoreSpi.engineLoad(Unknown Source)
at java.base/java.security.KeyStore.load(KeyStore.java:1473)
at it.finanze.sanita.fjm.Utility.extractKeyByAliasFromP12(Utility.java:58)
at it.finanze.sanita.fjm.Launcher.getTokens(Launcher.java:204)
at it.finanze.sanita.fjm.Launcher.buildTokens(Launcher.java:182)
at it.finanze.sanita.fjm.Launcher.main(Launcher.java:85)

An error occur while trying to generate JWT, hope this can help:
EXCEPTION: Key argument cannot be null.
java.lang.IllegalArgumentException: Key argument cannot be null.
at io.jsonwebtoken.lang.Assert.notNull(Assert.java:85)
at io.jsonwebtoken.impl.DefaultJwtBuilder.signWith(DefaultJwtBuilder.java:106)
at it.finanze.sanita.fjm.Launcher.generateAuthJWT(Launcher.java:403)
at it.finanze.sanita.fjm.Launcher.getTokens(Launcher.java:219)
at it.finanze.sanita.fjm.Launcher.buildTokens(Launcher.java:182)
at it.finanze.sanita.fjm.Launcher.main(Launcher.java:85)

L'errore è chiaramente legato al provider Criptografico BouncyCastle. Io nel mio ambiente JRE.1.8 ho impostato tale provider nel file di
java.security. Ovviamente non essendo un Jar standard ho provveduto a scaricare dal sito di BounctCastle i relativi Jar signed ma ottengo sempre lo stesso errore.

Ho necessità del tool per validare i token generati dai miei componenti software.....

@gdelgiovine
Copy link
Author

Buonasera, ho risolto il problema. Il vostro codice richiede obbligatoriamente una Alias per il certificato di signature del Jwt.

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

No branches or pull requests

1 participant