B4J Question [SOLVED] App works perfectly in debug but not in release

Gnappo jr

Active Member
Licensed User
Longtime User
i have an old jetty based app, i recently updated b4j to latest release 9.80 and I get this error: (java.security.InvalidKeyException: Wrong key size) when the app is launched from the build folder created with create package standalone, while the problem does not exist if run in debug mode in B4J.
the app uses the encryption 1.10 library
and #AdditionalJar: bcprov-jdk15on-154

I manually copied the bcprov-jdk15on-154.jar file to the bin, lib and root folders of the app but the problem persists


I attach error log:

Caused by: java.security.InvalidKeyException: Wrong key size
at java.base/com.sun.crypto.provider.DESedeCrypt.init(Unknown Source)
at java.base/com.sun.crypto.provider.CipherBlockChaining.init(Unknown Source)
at java.base/com.sun.crypto.provider.CipherCore.init(Unknown Source)
at java.base/com.sun.crypto.provider.DESedeCipher.engineInit(Unknown Source)
at java.base/javax.crypto.Cipher.implInit(Unknown Source)
at java.base/javax.crypto.Cipher.chooseProvider(Unknown Source)
at java.base/javax.crypto.Cipher.init(Unknown Source)
at java.base/javax.crypto.Cipher.init(Unknown Source)
at b4j/anywheresoftware.b4a.agraham.encryption.CipherWrapper.doFinal(Unknown Source)
at b4j/anywheresoftware.b4a.agraham.encryption.CipherWrapper.Decrypt(Unknown Source)
at b4j/b4j.example.webservice1._decrypt(Unknown Source)
at b4j/b4j.example.webservice1._handle(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
 
Last edited:

OliverA

Expert
Licensed User
Longtime User
If you are using the latest B4J, you will be using the latest jServer. That version needs JDK 11 and above. You may need to update your bouncy castle libs for JDK 11 and above
 
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User
If you are using the latest B4J, you will be using the latest jServer. That version needs JDK 11 and above. You may need to update your bouncy castle libs for JDK 11 and above
I updated the library #AdditionalJar: bcprov-jdk15on-165
Jetty is up to date as it is now a b4j standard library and is jserver 4-01
The problem remains the same!
Everything works fine in the B4J ide but not in the distributed package, tested on the same PC
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
For any Java above 8 you should be using a jdk18on version, with the latest being bcprov-jdk18on-172.jar
 
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User
For any Java above 8 you should be using a jdk18on version, with the latest being bcprov-jdk18on-172.jar
Thank you for your time and patience,
I tried the provider #AdditionalJar: bcprov-ext-jdk18on-172.jar but the problem persists.
What I can't understand why if started inside B4j everything works correctly?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
What I can't understand why if started inside B4j everything works correctly?
Try this?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
If the issue still persists, create a small demo program that replicates the issue and post here on the forum
 
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User
If the issue still persists, create a small demo program that replicates the issue and post here on the forum
Attached is a b4x program to review.
Are two equal programs one in b4a and one in b4j that encrypt and decrypt a string.
The b4a programwork in release mode. The b4j program if started from the B4J IDE works correctly, but the packaged standalone version when I press the CLICK key reports the error: java.security.NoSuchAlgorithmException: No such algorithm: DESEDE/CBC/PKCS5Padding
I tried manually copying the bcprov-ext-jdk18on-172.jar file into the lIb folder of the build folder but the problem persists.
How to get a working exe to distribute?


follow me
 

Attachments

  • testba.rar
    9 KB · Views: 115
  • Immagine 2023-03-29 081447.jpg
    Immagine 2023-03-29 081447.jpg
    32.9 KB · Views: 96
  • Immagine 2023-03-29 081644.jpg
    Immagine 2023-03-29 081644.jpg
    167.2 KB · Views: 103
Last edited:
Upvote 0

Gnappo jr

Active Member
Licensed User
Longtime User
The problem was solved by the XorAndOr user, the main solution was to use a 24-bit password instead of 16. Furthermore, this routine was modified by commenting the lines:

codice modificato:
Sub InitializeCipher(c As Cipher, transformation As String)
    c.Initialize(transformation)
'    Dim r As Reflector
'    Dim o As Object = r.RunStaticMethod("javax.crypto.Cipher", "getInstance", Array(transformation, "BC"), _
'     Array As String("java.lang.String", "java.lang.String"))
'    r.Target = c
'    r.SetField2("cipher", o)
End Sub


Italian link
 
Upvote 0
Top