Issue Type: Bug Bug
Affects Versions: JRuby 1.7.3, JRuby 1.7.4
Assignee: Thomas E Enebo
Created: 28/Feb/13 9:17 PM
Description:

Hi there,

I've noticed an issue when trying to set ssl_timeout on a Net::HTTP instance. My little test case, running against a build of https://github.com/jruby/jruby/commit/e51d09473490e7b04b721ba2d556346ab747f96c:

$ cat > test.rb
require 'net/http'
require 'uri'

uri = URI.parse("https://www.google.com/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.ssl_timeout = 5

http.request(Net::HTTP::Get.new(uri.request_uri))

EOF

$ java -cp jruby-complete.jar org.jruby.Main --1.9 test.rb
NoMethodError: undefined method `ssl_timeout=' for #<OpenSSL::SSL::SSLContext:0x422758d0>
    __send__ at org/jruby/RubyBasicObject.java:1683
  set_params at jar:file:/home/mst/tmp/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.9/openssl/ssl-internal.rb:38
        each at org/jruby/RubyHash.java:1281
  set_params at jar:file:/home/mst/tmp/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.9/openssl/ssl-internal.rb:38
     connect at jar:file:/home/mst/tmp/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:775
    do_start at jar:file:/home/mst/tmp/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:755
       start at jar:file:/home/mst/tmp/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:744
     request at jar:file:/home/mst/tmp/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.9/net/http.rb:1292
      (root) at test.rb:11

It seems that this bug was fixed in MRI Ruby by aliasing ssl_timeout= to timeout=:

https://github.com/ruby/ruby/commit/ce2b574017cacc2c3f2b0e92f82a7f250639fc34

I applied a similar fix locally and that seemed to do the trick, but wasn't sure if this was the best place for the fix:

diff --git a/lib/ruby/1.9/openssl/ssl-internal.rb b/lib/ruby/1.9/openssl/ssl-internal.rb
index c70b5b8..b2e29d3 100644
--- a/lib/ruby/1.9/openssl/ssl-internal.rb
+++ b/lib/ruby/1.9/openssl/ssl-internal.rb
@@ -27,6 +27,8 @@ module OpenSSL
         :options => OpenSSL::SSL::OP_ALL,
       }
 
+      alias ssl_timeout= timeout=
+
       DEFAULT_CERT_STORE = OpenSSL::X509::Store.new
       DEFAULT_CERT_STORE.set_default_paths
       if defined?(OpenSSL::X509::V_FLAG_CRL_CHECK_ALL)

Please let me know if I can lend a hand with testing,

Mark

Project: JRuby
Priority: Minor Minor
Reporter: Mark Triggs
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to