Error: java.security.InvalidKeyException: Illegal key size or default parameters



Java can find corresponding implementations for almost all kinds of commonly used encryption algorithms. Because of the export restrictions in the United States, Sun has made corresponding restrictions through the authorization files (local_policy.jar, US_export_policy.jar). Therefore, there are some problems:
●The key length cannot meet the requirements (such as: java.security.InvalidKeyException: Illegal key size or default parameters);
●Some algorithms are not supported, such as MD4, SHA-224 and other algorithms;
●The API is used It is not very convenient; some common base conversion auxiliary tools are not provided, such as Base64 encoding conversion, hexadecimal encoding conversion and other tools.
    Oracle provides Unlimited Strength Jurisdiction Policy Files on its official website. We only need to deploy it in the JRE environment to solve the restriction problem.
Download address:
1. Java 5.0 policy-free file
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-plat-419418.html#jce_policy-1.5.0-oth -JPR
2, Java 6 no policy restriction file
http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
3, Java 7 no policy restriction file
http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
4. Other versions have no policy restrictions
http://www.oracle.com/technetwork/java/javasebusiness There is only one directory in the compressed package downloaded by /downloads/java-archive-downloads-java-plat-419418.html
      , which is the jce directory. This directory contains 4 files: README.txt, COPYRIGHT.html, local_policy.jar and US_export_policy.jar. The two jar files included are the files used in this configuration.
      We can view the above README.txt file. You need to configure the above two jar files in the JRE environment of the JDK, or in the JRE environment.
      Switch to the %JDK_Home%\jre\lib\security directory and overwrite the local_policy.jar and US_export_policy.jar files accordingly. At the same time, you may need to overwrite these two files in the %JRE_Home%\lib\security directory.
      The ultimate purpose of configuring the permissions file is to enable the application to obtain the corresponding permissions in the running environment, which can enhance the security of the application. Usually, we install the JRE on the application server, not the JDK. Therefore, it is necessary to overwrite these two permission files in the %JRE_Home%\lib\security directory of the application server. Many developers tend to ignore this, leading to accidents.

【Shiwei Technology Department】

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326197070&siteId=291194637