Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

部分JDK报java.security.InvalidKeyException: Illegal key size #5

Closed
NotFound403 opened this issue Jan 31, 2021 · 4 comments
Closed
Assignees
Labels
comppatibility there is a comppatibility question Further information is requested

Comments

@NotFound403
Copy link
Collaborator

Caused by: cn.felord.payment.PayException: java.security.InvalidKeyException: Illegal key size
at cn.felord.payment.wechat.v3.SignatureProvider.decryptResponseBody(SignatureProvider.java:263) ~[payment-spring-boot-autoconfigure-1.0.4.RELEASE.jar!/:na]
at cn.felord.payment.wechat.v3.SignatureProvider.lambda$refreshCertificate$0(SignatureProvider.java:220) ~[payment-spring-boot-autoconfigure-1.0.4.RELEASE.jar!/:na]
at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_131]

@NotFound403
Copy link
Collaborator Author

对于密码,很多国家是限制出口的,因此你可能使用了受限制的JDK,尤其是Oracle的JDK。解决方案:

前往甲骨文官网下载JCE无限制权限策略文件,例如JDK8:

https://www.oracle.com/java/technologies/javase-jce8-downloads.html

下载下来后对文件进行解压发现其中有两个jar包,将其复制并覆盖你自己的%JAVA_HOME%/jre/lib/security下的local_policy.jar 和 US_export_policy.jar

注意:覆盖之前最好将原来的local_policy.jar 和 US_export_policy.jar 备份

@NotFound403
Copy link
Collaborator Author

或者更换为Open JDK 也可以突破限制

@wanghe-sudo
Copy link

jdk8 151之前需要替换jar包,151版本以后,只需要手动开启配置,找到jre路径,找到java.security文件,去除crypto.policy=unlimited注释(约826行)

@lonffreytu
Copy link

jdk8 151之前需要替换jar包,151版本以后,只需要手动开启配置,找到jre路径,找到java.security文件,去除crypto.policy=unlimited注释(约826行)

该文件在 jre\lib\security,亲测通过

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comppatibility there is a comppatibility question Further information is requested
Projects
No open projects
payment-spring-boot
Awaiting triage
Development

No branches or pull requests

3 participants