Ale*_*ang 21 openssl jruby heroku ruby-on-rails-4
Rails4默认使用加密的cookie会话存储.当应用程序尝试加密cookie时,会引发以下错误:OpenSSL::Cipher::CipherError: Illegal key size: possibly you need to install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files for your JRE
(stacktrace:https://gist.github.com/8ba56b18060ae30e4d44 ).
正如这里提到的,这可以通过降级加密或安装JCE来解决 - 第一个是我真的不想做的事情而后者在heroku上是不可能的(afaik).
Leo*_*ons 18
不确定它是否适用于Heroku,但这解决了我当地Jruby 的问题.
创建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
Run Code Online (Sandbox Code Playgroud)
Heroku 开发中心现在有这篇文章:“自定义 JDK”。
\n\n\n\n\n在某些情况下,文件需要与 JDK 捆绑在一起,以便在运行时 JVM 中公开功能。例如,JDK 中经常添加无限强度的 Java 加密扩展 (JCE),以便利用更强大的加密库。为了处理这种情况,Heroku 会将 .jdk-overlay 文件夹中应用程序指定的文件复制到 JDK\xe2\x80\x99s 目录结构中。
\n
以下是将 JCE 文件添加到您的应用程序的方法:
\n\n在你的application\xe2\x80\x99s根目录下,创建一个.jdk-overlay
文件夹
将 JCElocal_policy.jar
复制US_export_policy.jar
到.jdk-overlay/jre/lib/security/
提交文件
\n\n\n$ git add .jdk-overlay
\n
\n $ git commit -m "自定义 JCE 文件"
部署到 Heroku
\n\n\n$ git push heroku master
\n
归档时间: |
|
查看次数: |
4348 次 |
最近记录: |