Skip to content

Instantly share code, notes, and snippets.

@mpepping
Created February 1, 2015 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpepping/ca91bcb687f50ab467d5 to your computer and use it in GitHub Desktop.
Save mpepping/ca91bcb687f50ab467d5 to your computer and use it in GitHub Desktop.
OpenSSL::Cipher::CipherError with Rails3/4 on 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment