Home >Java >javaTutorial >How to Fix the 'Illegal Key Size or Default Parameters' Exception in Java After a JVM Update?

How to Fix the 'Illegal Key Size or Default Parameters' Exception in Java After a JVM Update?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-12-19 11:32:11901browse

How to Fix the

Java Security: Resolving Illegal Key Size Exception

In Java, the use of encryption algorithms with strong key sizes may require additional permissions or policy files. The exception "Illegal key size or default parameters" typically arises when attempting to utilize a key size that exceeds the default or permitted limits.

In your case, after upgrading to Java 1.6.0.26, you encountered this issue when running code that previously executed flawlessly in Java 1.6.0.12. This suggests that something has changed in the Java installation configuration.

Solution:

The most probable explanation is the absence of the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files. These files are necessary for enabling strong encryption algorithms in Java.

To resolve this, you need to obtain the Unlimited Strength Policy files for your Java version:

  • Java 1.6: Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6
  • Java 1.7: Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 7
  • Java 8 (before u162): Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 8

Once downloaded, extract the JAR files from the ZIP archive and place them in the following directory:

${java.home}/jre/lib/security/

Restart your Java application, and the "Illegal key size or default parameters" exception should be resolved.

The above is the detailed content of How to Fix the 'Illegal Key Size or Default Parameters' Exception in Java After a JVM Update?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn