获取“OpenSSL 读取服务器证书 B:证书验证失败”错误,但仅适用于 Twitter
我有一个 Rails 网站 (reccr.com),它使用omniauth 通过多种不同的选项对用户进行身份验证,包括 Facebook 和 Twitter(使用 OAuth)以及其他一些选项(使用 OpenID)。然而,最近(我认为在上周左右)尝试通过 Twitter 进行身份验证会抛出
OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read servercertificate B:certificate verify failed )
错误,但只有 Twitter 会这样做;所有其他服务都可以很好地进行身份验证。我一直在互联网上寻找解决方案,但我能找到的关于该错误的所有内容都解决了所有身份验证提供程序发生的情况,而我找不到的任何内容都适用于仅在一个特定提供程序中发生的情况。
据我所知(而且我是唯一的开发者)该网站没有发生任何改变,我认为任何会导致 Twitter 出现此问题的网站更改也会导致同样的问题Facebook OAuth 身份验证。
关于如何解决这个问题有什么想法吗?我最初希望问题出在 Twitter 端,他们会在几天内修复它,但已经过去了大约一周,而且问题仍在继续,而且我还没有看到任何其他针对此错误的 Twitter 特定投诉所以我开始怀疑到底是我。
编辑:好的,在发现 THIS 和 这个,我已经完成一半了。我正在尝试实现添加 :client_options =>; 的解决方案{:ca_file => '#{Rails.root}/config/ca-bundle.crt'}
到我的omniauth.rb 中的行末尾,我在其中声明 Twitter 为我的提供商之一。但是,当我这样做时,我在 lib/rack/builder.rb:54:in
initialize'` 处收到参数数量错误(4 for 3)
错误。有什么想法可以解决这个问题吗?
I have a rails website (reccr.com) that uses omniauth to authenticate users with several different options, including Facebook and Twitter (using OAuth) and a few others (using OpenID). Lately, however, (I think within the last week or so) trying to authenticate via Twitter throws that
OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed)
error, but ONLY Twitter does it; every other service authenticates just fine. I've been scouring the internet for a solution, but everything I can find on that error addresses situations where it occurs with ALL authentication providers, and nothing I can find applies to situations where it's only happening with one specific provider.
As far as I know (and I'm the sole developer) nothing had changed about the site that would have predicated this, and I would think that any change to the site that would cause this problem with Twitter would also cause the same problem with Facebook OAuth authentication.
Any ideas on how I can fix this? I was initially hoping that the problem was on Twitter's end and that they'd fix it in a couple of days, but it's been about a week and it's still ongoing, and I haven't seen any other Twitter-specific complaints about this error so I'm starting to suspect it's me after all.
EDIT: OK, after discovering THIS and THIS, I'm halfway there. I'm trying to implement the solution where I add a :client_options => {:ca_file => '#{Rails.root}/config/ca-bundle.crt'}
to the end of the line in my omniauth.rb where I declare Twitter as one of my providers. However, when I do that I get a wrong number of arguments (4 for 3)
error at lib/rack/builder.rb:54:in
initialize'`. Any ideas how to fix that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常此错误意味着 Ruby 无法在本地计算机上找到验证服务器提供的证书集,看看这篇博客文章是否可以帮助您。 http://martinottenwaelter.fr/2010/12/ruby19-and- the-ssl-错误/
Usually this error means that Ruby cant find the set of certificates on the local machine that verify those provided from the server, see if this blog post can help you out. http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/
好吧,事实证明这是一堆东西。
Twitter 已更改其 SSL 证书,如此处所述。 (我昨晚无法阅读,因为 dev.twitter.com 已关闭!)
Omniauth 使用 oauth,它有一个错误,迫使它使用特定的 CA 文件而不是更通用的 CA 路径,详细信息 此处。
解决方案之一是在omniauth 中初始化提供程序时指定正确的 CA 文件,但是当我尝试这样做时,我不断收到“参数数量错误”错误。在经历了一系列的意外之后,我完全卸载并重新安装了 Rails,它不再给我这个错误,所以我能够为omniauth 添加该规范,现在它可以再次向 Twitter 进行身份验证!万岁!
不幸的是,在所有这一切中的某个地方,它无法通过 Facebook 进行身份验证,但我确信我能弄清楚为什么会发生这种情况。
OK, it turns out it was a bunch of stuff.
Twitter had changed their SSL certificate, as mentioned HERE. (Which I couldn't read last night because dev.twitter.com was down!)
Omniauth uses oauth, which has a bug that forces it to use a specific CA file rather than a more general CA path, as detailed HERE.
One of the solutions is to specify a correct CA file when initializing your provider in omniauth, however I kept getting "wrong number of arguments" errors when I tried to do that. After a long series of mishaps which ended in my completely uninstalling and reinstalling rails, it stopped giving me that error, so I was able to add that specification for omniauth, and now it can authenticate to Twitter again! Hooray!
Unfortunately, somewhere in all of this it stopped being able to authenticate to Facebook, but I'm sure I can figure out why that's happening.