encryptionbouncycastlejavapolicyfiles

Using encryption that would need Java Policy Files in openjre


if i want to use java and encryption with keys longer than 128bit i have to use the Java Policy Files. How to get those applications up and running with openjre? I get the same error i get using oracle jre without policy files, but i can't simply use the Oracle Policy Files? or can i?

Or would building the project with openjdk help?

Thank You


Solution

  • I found the following. It seems to solve all the policy problems i ever had.

      try {
        Field field = Class.forName("javax.crypto.JceSecurity").getDeclaredField("isRestricted");
        field.setAccessible(true);
        field.set(null, java.lang.Boolean.FALSE);
      } catch (Exception ex) {
    
      }
    

    It's not nice but working!