0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JDK VerUpに伴うSecurityException

0
Posted at

前提

Javaには、Cipherという暗号化/復号化を行うクラスが用意されているが、
デフォルトのままだとAESの鍵の長さは128bitしか使えなかった。
ただし、Javaのポリシーファイルを書き換えれば256bitまで使用することが可能となるため、
256bitまで使用可能となるJavaのポリシーファイルを別途インストールするHackが行われていた。

問題事象

8u261にJDKを上げてみたところ、起動はするものの、実行時エラーとして以下のようなExceptionが発生した。

Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
        at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:93)
        ... 113 common frames omitted
Caused by: java.lang.SecurityException: The jurisdiction policy files are not signed by the expected signer! (Policy files are specific per major JDK release.Ensure the correct version is installed.)
        at javax.crypto.JarVerifier.verifyPolicySigned(JarVerifier.java:336)
        at javax.crypto.JceSecurity.loadPolicies(JceSecurity.java:378)
        at javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:323)
        at javax.crypto.JceSecurity.access$000(JceSecurity.java:50)
        at javax.crypto.JceSecurity$1.run(JceSecurity.java:85)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:82)

 対処

以下のPolicyファイルのインストールを止める。それだけ。

  • local_policy.jar
  • US_export_policy.jar

原因

2018年1月(8u161、7u171)以降、無制限のJava暗号化拡張機能(JCE)管轄ポリシーファイルがJDKにバンドルされ、デフォルトで有効になっています(JDK 暗号化ロードマップを参照)。
古いスタンドアロンjarの証明書は有効期限が切れています。使用すると、次の例外が表示されます。
https://www.oracle.com/java/technologies/javase/8u261-relnotes.html

2年前にこの制約なくなってたんだね…。知らなかったよ。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?