Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: uninitialized constant OpenSSL::SSL::Session with jruby #207

Closed
jhund opened this issue Feb 22, 2012 · 2 comments
Closed

NameError: uninitialized constant OpenSSL::SSL::Session with jruby #207

jhund opened this issue Feb 22, 2012 · 2 comments

Comments

@jhund
Copy link

jhund commented Feb 22, 2012

When using mechanize to fetch the following https URL, I get the error listed in the title:

agent = Mechanize.new
agent.redirect_ok = :all
agent.follow_meta_refresh = true
agent.user_agent = "My user agent"
agent.keep_alive = false
agent.open_timeout = 20
agent.read_timeout = 20

agent.get("https://plus.google.com/u/0/111091089527727420853/posts/QSraHjCsFZk")
=> NameError: uninitialized constant OpenSSL::SSL::Session

I'm not sure if this is related to net-http-persistent-2.5.2 or to jruby-openssl ? If so, let me know and I'll repost there.

My environment:

Some additional notes:

  • I found this ticket on the jruby issue tracker: "Implement OpenSSL::SSL::Session object" (http://jira.codehaus.org/browse/JRUBY-4371)
  • I have made sure that Certificate verification works on my dev system. The snippet below works fine:
uri = URI.parse("https://plus.google.com/u/0/111091089527727420853/posts/QSraHjCsFZk")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.request_get(uri.path)
 => #<Net::HTTPOK 200 OK readbody=true> 

Sorry that this is not as detailed as I'd like it to be. I'm still trying to figure out where I should report this. Since it became visible after I upgraded Mechanize from 2.0.1 to 2.2.1, I'm starting here, ready to move on to underlying libraries as required.

Thanks for any pointers you can give me.

Cheers

Jo

@drbrain
Copy link
Member

drbrain commented Feb 22, 2012

The source of this bug is net-http-persistent which has a Net::HTTP subclass which reuse SSL sessions to speed up reconnections (50-100ms improvement for https://www.google.com).

You can disable this through private API in mechanize:

m = Mechanize.new
m.agent.reuse_ssl_sessions = false

I'll expose this setting via the Mechanize instance in the next release.

@jhund jhund closed this as completed Feb 22, 2012
@jhund
Copy link
Author

jhund commented Feb 22, 2012

thanks a lot for the quick response. I got it to work (after I slightly modified your fix by adding the 'http' method):

m = Mechanize.new
m.agent.http.reuse_ssl_sessions = false

Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants