Skip to content

Instantly share code, notes, and snippets.

@dalyons
Created December 2, 2011 23:25
Show Gist options
  • Save dalyons/1425320 to your computer and use it in GitHub Desktop.
Save dalyons/1425320 to your computer and use it in GitHub Desktop.
openssl hax needed to get a fairly standard rails3.1 app going on JRuby 1.6.x
if defined?(JRUBY_VERSION)
#Hackily implement a missing method in JRuby net library that causes:
# undefined method `read_nonblock' for #<OpenSSL::SSL::SSLSocket:0xb692bc4>
#
#See: http://jira.codehaus.org/browse/JRUBY-5529
#
#In my case, its trigger from faraday in the oauth2 gem.
Net::BufferedIO.class_eval do
BUFSIZE = 1024 * 16
def rbuf_fill
timeout(@read_timeout) {
@rbuf << @io.sysread(BUFSIZE)
}
end
end
#Disable ssl verification, otherwise we get
# OpenSSL::SSL::SSLError
# certificate verify failed
# when we try to connect to a https site.
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment