gpt4 book ai didi

java - key 大小非法 : possibly you need to install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files for your JRE

转载 作者:太空宇宙 更新时间:2023-11-04 12:13:05 25 4
gpt4 key购买 nike

我正在将 jruby 与 Rails 一起使用。我的机器上安装了JDK7。每当我启动 Rails 服务器并尝试运行我的应用程序时,我都会收到错误 “非法 key 大小:可能您需要为您的 JRE 安装 Java 加密扩展 (JCE) 无限强度管辖策略文件”

我在google上搜索发现我必须下载JDK-7安全策略文件。所以我从here下载了这些文件并将这些文件放入我的java目录路径 "C:\Program Files\Java\jdk1.7.0_79\jre\lib\security" 。我认为这会解决我的问题,但我仍然遇到同样的错误。

在 java 的安全文件夹中粘贴文件时,我收到警告框,其信息为“您需要提供管理权限才能复制此文件夹”。我点击了警报框的继续按钮,文件被复制。

我一定错过了一些东西。

请帮忙

最佳答案

我创建了一个包含以下内容的文件 config/initializers/unlimited_strength_cryptography.rb 并且它有效

if RUBY_PLATFORM == 'java' # Allows the application to work with other Rubies if not JRuby
require 'java'
java_import 'java.lang.ClassNotFoundException'

begin
security_class = java.lang.Class.for_name('javax.crypto.JceSecurity')
restricted_field = security_class.get_declared_field('isRestricted')
restricted_field.accessible = true
restricted_field.set nil, false
rescue ClassNotFoundException => e
# Handle Mac Java, etc not having this configuration setting
$stderr.print "Java told me: #{e}n"
end
end

关于java - key 大小非法 : possibly you need to install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files for your JRE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39686447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com