ruby-openid: @socket not set while performing discovery

313 views Asked by At

I'm having a bit of truble with omniauth/openid.

When trying to authenticate, I found this in my logs:

OpenID::FetchingError: Error fetching https://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username: undefined method `io' for nil:NilClass

The important thing there is undefined method io' for nil:NilClass which comes from openid/fetchers.rb, in the following snippet:

module Net
class HTTP
def post_connection_check(hostname)
  check_common_name = true
  cert = @socket.io.peer_cert
  cert.extensions.each { |ext|
    next if ext.oid != "subjectAltName"
    ext.value.split(/,\s+/).each{ |general_name|
      if /\ADNS:(.*)/ =~ general_name
        check_common_name = false
...

That error is generated by @socket.io.peer_cert, @socket is not defined.

Have any of you encountered this before? Not quite sure what the cause is.

Versions I'm running:

  • ruby 1.9.3dev (2010-08-17 trunk 29020) [x86_64-darwin10.4.0]
  • ruby-openid (2.1.8)
  • ruby-openid-apps-discovery (1.2.0)
  • omniauth 0.2.0
2

There are 2 answers

0
flipstone On

We had this same problem and it was a direct result of Net::HTTP#connect never being invoked. Turns out we had the fakeweb gem scoped into the environment that was throwing the error (development, in our case).

Narrowing fakeweb's scope allows for normal processing of #connect and @socket is once again happy.

group :test do
  gem 'fakeweb'
end
0
gingerlime On

We came across the same / very similar problem with both fakeweb and webmock (when using the VCR gem). Switching from fakeweb to typhoeus seemed to have solved this problem for us.