2

this is my code:

static {
    Security.addProvider(new BouncyCastleProvider());
}

...

final Cipher sifra = Cipher.getInstance("AES/CBC/PKCS7Padding");

Junit works fine but When I deploy my application to weblogic server I got these exception:

java.security.NoSuchAlgorithmException: Cannot find any provider supporting AES/CBC/PKCS7Padding

Can you hlp me what is wrong ?

hudi
  • 15,555
  • 47
  • 142
  • 246

1 Answers1

2

That's the old strange problem of different versions and missing cryptography files. I believe PKCS5Padding instead of PKCS7Padding will work. Anyway, it has something to do with Unlimited Strength Jurisdiction Policy Files which can be downloaded from Oracle ... or some other missing part or old version of Java Cryptography Extension.

Petr Janeček
  • 37,768
  • 12
  • 121
  • 145
  • hm that is nice but I have to use PKCS7 not 5 – hudi Mar 30 '12 at 12:19
  • They are effectively interchangeable for block sizes up to 256. Absolutely the same. But if you must, then the Unlimited Strength Jurisdiction Policy Files are your ticket to ride. – Petr Janeček Mar 30 '12 at 12:29
  • it is a business requirement so I have no choice – hudi Mar 30 '12 at 12:42
  • 2
    ok I add security.provider.N=org.bouncycastle.jce.provider.BouncyCastleProvider to java.security file and now it works thx a lot vdaka :) – hudi Mar 30 '12 at 13:12
  • Doesn't work for me. I am facing the same issue. the app works all good locally but the error comes out when it runs on a remote Jboss application server – Gelin Luo Mar 04 '14 at 10:27