Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby-openid: @socket not set while performing discovery

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
like image 247
Andrei Serdeliuc ॐ Avatar asked Mar 19 '11 10:03

Andrei Serdeliuc ॐ


2 Answers

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
like image 153
flipstone Avatar answered Nov 20 '22 10:11

flipstone


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.

like image 24
gingerlime Avatar answered Nov 20 '22 09:11

gingerlime