Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.5
-
Fix Version/s: JRuby 1.7.1
-
Component/s: OpenSSL, Ruby 1.9.3
-
Labels:
-
Environment:Red Hat 5, jruby 1.6.5 (ruby 1.9 mode)
-
Number of attachments :
Description
I opened an issue on Github but wasn't sure which bug tracker is preferred, so I'm putting it here as well.
In Ruby (at least 1.9.x) the OpenSSL::X509::Certificate and OpenSSL::PKey::RSA constructors accept a File or String, such as:
OpenSSL::X509::Certificate.new File.open("/path/to/my.crt") OpenSSL::X509::Certificate.new File.read("/path/to/my.crt")
However, JRuby (at least 1.6.5 and 1.6.7) only accept a String:
OpenSSL::X509::Certificate.new File.open("/path/to/my.crt") #=> TypeError: can't convert File into String OpenSSL::X509::Certificate.new File.read("/path/to/my.crt") #=> this works
I believe the error created when passing a File to the OpenSSL::X509::Certificate constructor comes from X509Cert which in turn calls OpenSSLImpl. – the call to "arg.toconvertToString" seems to be the problem.
I believe the error created when passing a File to the OpenSSL::PKey::RSA constructor comes from here – the call to "arg.toconvertToString" seems to be the problem.
commit 5a0cb0b79e161bb17ac6c26febcf1ba9ace23402 Author: Charles Oliver Nutter <headius@headius.com> Date: Tue Oct 30 22:21:43 2012 -0500 Fix #152 and JRUBY-6636 OpenSSL::X509::Certificate and OpenSSL::PKey::RSA constructors don't accept File objects Added logic for reading a passed-in IO object fully to get the cert. Added test to MRI 1.9 suite. PR pending. :100644 100644 7363dd8... a439648... M src/org/jruby/ext/openssl/OpenSSLImpl.java :100644 100644 f81320b... 4b760c4... M test/externals/ruby1.9/openssl/test_certificate.rb