ruby-openid:执行发现时未设置@socket

And*_*c ॐ 5 ruby ruby-openid omniauth net-http

我与omniauth/openid有点混乱.

在尝试进行身份验证时,我在日志中发现了这一点:

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
Run Code Online (Sandbox Code Playgroud)

重要的是undefined method io' for nil:NilClass来自openid/fetchers.rb,在下面的代码片段中:

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
...
Run Code Online (Sandbox Code Playgroud)

该错误是由@socket.io.peer_cert@socket未定义生成的.

你们有没有遇到过这个?不太确定原因是什么.

我正在运行的版本:

  • 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)
  • omn​​iauth 0.2.0

小智 7

我们遇到了同样的问题,这是Net :: HTTP #connect永远不会被调用的直接结果.事实证明,我们将假网络宝石放在了引发错误的环境中(在我们的例子中是开发).

缩小fakeweb的范围允许正常处理#connect和@socket再次感到高兴.

group :test do
  gem 'fakeweb'
end
Run Code Online (Sandbox Code Playgroud)