エラーキーのサイズが不正です
Java環境
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
解決
以前触れなかったことが 1 つあります。それは、/usr/local/java/jdk1.8.0_151/jre/lib/security/policy/
以下に。
[root@djx-117106 policy]# pwd
/usr/local/java/jdk1.8.0_151/jre/lib/security/policy/
[root@djx-117106 policy]# ls -l
total 8
drwxr-xr-x 2 root root 4096 Nov 2 10:47 limited
drwxr-xr-x 2 root root 4096 Nov 2 10:47 unlimited
[root@djx-117106 policy]# ls -l ./limited/
total 8
-rw-r--r-- 1 root root 3405 Jul 4 19:41 local_policy.jar
-rw-r--r-- 1 root root 2920 Jul 4 19:41 US_export_policy.jar
[root@djx-117106 policy]# ls -l ./unlimited/
total 8
-rw-r--r-- 1 root root 2929 Jul 4 19:41 local_policy.jar
-rw-r--r-- 1 root root 2917 Jul 4 19:41 US_export_policy.jar
ディレクトリ (つまり、復号化に制限があり、128 ビットのみをサポートするパッケージ) と、 ディレクトリ (つまり、制限のないディレクトリ)limited
があります 。ulimited
ソースコードを変更する
これについては、以下の文書で確認できます/usr/local/java/jdk1.8.0_151/jre/lib/security/
。 java.security
# To support older JDK Update releases, the crypto.policy property
# is not defined by default. When the property is not defined, an
# update release binary aware of the new property will use the following
# logic to decide what crypto policy files get used :
#
# * If the US_export_policy.jar and local_policy.jar files are located
# in the (legacy) <java-home>/lib/security directory, then the rules
# embedded in those jar files will be used. This helps preserve compatibility
# for users upgrading from an older installation.
#
# * If crypto.policy is not defined and no such jar files are present in
# the legacy locations, then the JDK will use the limited settings
# (equivalent to crypto.policy=limited)
#
# Please see the JCA documentation for additional information on these
# files and formats.
#crypto.policy=unlimited
以下の手順は (equivalent to crypto.policy=limited)
デフォルトで使用されること に注意してくださいlimited
。デフォルトの使用を制限しないようにするには、.
を追加するだけです 。crypto.policy=unlimited
Jar パッケージを置き換える
/usr/local/java/jdk1.8.0_151/jre/lib/security/policy/limited
パッケージへのパスを置き換えます 。実際、 /usr/local/java/jdk1.8.0_151/jre/lib/security/policy/unlimited
次の /usr/local/java/jdk1.8.0_151/jre/lib/security/policy/limited/
2 つのパッケージを次のパッケージに直接置き換えることができます。つまり、制限のない jar パッケージがデフォルトで使用されます。
Javaのバージョンをアップグレードする
Java™ SE Development Kit 8, Update 161 の
公式ドキュメントには次のように書かれています。
security-libs/javax.crypto
Unlimited cryptography enabled by default
The JDK uses the Java Cryptography Extension (JCE) Jurisdiction Policy files to configure cryptographic algorithm restrictions. Previously, the Policy files in the JDK placed limits on various algorithms. This release ships with both the limited and unlimited jurisdiction policy files, with unlimited being the default. The behavior can be controlled via the new 'crypto.policy' Security property found in the /lib/java.security file. Please refer to that file for more information on this property.
つまり、 1.8.0_161-b12
このバージョン以降、デフォルトで無制限の暗号化アルゴリズムが使用されることになります。つまり、 unlimited
以下の jar パッケージが使用されます。java.security
ファイル crypto.policy
の値を設定することで、このデフォルト値を変更することもできます 。