- Goal: In JRuby, run and load a Java JAR that is compiled against bcprov 1.5
As currently configured, this project will load and run
(see bouncy_castle_client.rb
). However, if the version of BouncyCastle that is
bundled with JRuby (1.4.7) is loaded (see bouncy_castle_collision.rb
), the project fails to load the JAR correctly.
Instructions:
set_up_files.sh # Github gists don't allow directories
mvn package
ruby bouncy_castle_client.rb # ok
ruby bouncy_castle_collision.rb # errors
In pom.xml, line 15, you can make this Square-agnostic:
(It still shows the same issue.)
Poking around a bit, I'm guessing the issue you're seeing at runtime is because, by the time you're running your code, openssl has already been
require
d. That in turn loadsshared/jopenssl/load.rb
, which then requires the older versions of BouncyCastle (viarequire 'bouncy-castle-java'
).E.g.,
~/.rvm/rubies/jruby-1.7.9/lib/ruby grep -rl "require 'openssl'" * 1.8/drb/ssl.rb 1.8/net/https.rb 1.8/net/smtp.rb 1.8/webrick/ssl.rb 1.9/digest/hmac.rb 1.9/drb/ssl.rb 1.9/net/https.rb 1.9/net/smtp.rb 1.9/webrick/ssl.rb 1.9/webrick.rb 2.0/drb/ssl.rb 2.0/net/https.rb 2.0/net/smtp.rb 2.0/openssl/digest.rb 2.0/ssl.rb 2.0/webrick/ssl.rb gems/shared/gems/activesupport-3.2.16/lib/active_support/message_encryptor.rb gems/shared/gems/activesupport-3.2.16/lib/active_support/message_verifier.rb gems/shared/gems/jruby-openssl-0.9.4/lib/jopenssl18/openssl/bn.rb gems/shared/gems/jruby-openssl-0.9.4/lib/jopenssl18/openssl/cipher.rb gems/shared/gems/jruby-openssl-0.9.4/lib/jopenssl18/openssl/config.rb gems/shared/gems/jruby-openssl-0.9.4/lib/jopenssl18/openssl/digest.rb gems/shared/gems/jruby-openssl-0.9.4/lib/jopenssl18/openssl/ssl.rb gems/shared/gems/jruby-openssl-0.9.4/lib/jopenssl18/openssl/x509.rb gems/shared/gems/jruby-openssl-0.9.4/lib/jopenssl19/openssl/ssl.rb gems/shared/gems/jruby-openssl-0.9.4/lib/jopenssl19/openssl/x509.rb gems/shared/gems/rack-1.4.5/lib/rack/session/cookie.rb shared/jopenssl18/openssl/bn.rb shared/jopenssl18/openssl/cipher.rb shared/jopenssl18/openssl/config.rb shared/jopenssl18/openssl/digest.rb shared/jopenssl18/openssl/ssl.rb shared/jopenssl18/openssl/x509.rb shared/jopenssl19/openssl/ssl.rb shared/jopenssl19/openssl/x509.rb shared/jopenssl21/openssl/digest.rb shared/rubygems/commands/cert_command.rb shared/rubygems/security/policy.rb shared/rubygems/security.rb
It's unclear who's loading BouncyCastle first in your runtime environment. I'd suspect it's either happening while loading a signed Gem (not jar!) or maybe as a result of some https/ssl stuff happening in Jetty or while bootstrapping some other communication library you need.