JRuby OpenSSL Error


倖福魔咒の 提交于 2019-12-05 00:20:26

问题


I am having problems configuring JRuby to work properly with OpenSSL. Googling has revealed that this is a pretty common occurence, but none of the solutions I've read have worked for me. Here is my setup:

  • Ubuntu 9.10
  • jruby 1.5.1
  • jruby-openssl (0.7)

Here is the error:

irb(main):001:0> require 'jruby/openssl/gem_only'
=> true
irb(main):002:0> require 'openssl'
=> true
irb(main):003:0> OpenSSL::Digest::OPENSSL_VERSION_NUMBER
NameError: uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER

Interestingly, require 'openssl' returns true even if I don't have the jruby-openssl gem installed. According to this link, that shouldn't happen?

Trying to load the gem explictly with require 'rubygems' and gem 'jruby-openssl' doesn't help.


回答1:


Are you sure you are looking at the right constant?

$ ruby -v -r openssl -e 'p OpenSSL::Digest::OPENSSL_VERSION_NUMBER'
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
-e:1: uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER (NameError)

$ ruby -v -r openssl -e 'p OpenSSL::OPENSSL_VERSION_NUMBER'
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
9470159

$ jruby -v -r openssl -e 'p OpenSSL::OPENSSL_VERSION_NUMBER'
jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06 f3a3480) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [x86_64-java]
9469999


来源:https://stackoverflow.com/questions/3261745/jruby-openssl-error

工具导航Map