gpt4 book ai didi

ruby-on-rails - Rails 2.3.x & 考拉 & Facebook : certificate verify failed

转载 作者:太空宇宙 更新时间:2023-11-03 13:55:58 26 4
gpt4 key购买 nike

我正在尝试使用 Koala 让 Facebook Graph API 在 Rails 2.3.5 中工作。在我的开发环境 (Mac) 中一切正常,但在生产环境 (Ubuntu 8.04.1) 中失败。

测试代码:

cookies = {"__utma"=>"158657023.1470934917.1315425280.1317394623.1317406089.55", "28aac256bbbe09dcae1eb7086ae1c326"=>"c14d42fcd1a6700aa6198a2ecd7587fa", "fbsetting_28aac256bbbe09dcae1eb7086ae1c326"=>"{\"connectState\":1,\"oneLineStorySetting\":3,\"shortStorySetting\":3,\"inFacebook\":false}", "__utmb"=>"158657023.23.10.1317406089", "28aac256bbbe09dcae1eb7086ae1c326_session_key"=>"c76e09e8124a194e26a9c1e9.1-635077092", "28aac256bbbe09dcae1eb7086ae1c326_user"=>"635077092", "__utmc"=>"158657023", "28aac256bbbe09dcae1eb7086ae1c326_expires"=>"0", "__utmz"=>"158657023.1317406089.55.52.utmcsr=angel.co|utmccn=(referral)|utmcmd=referral|utmcct=/thingspotter", "fbs_265881436784759"=>"\"access_token=AAADx0ViXiHcBAFMuyXsGRdZB4GmmHyZBQl9h7Ymqi6z0kk3ko5jRJGmdWZCdJQm7dWg2nCyraaZCJuJ6iurPxDHL6bZCMzosZD&expires=0&secret=815a69d93434d26034ada92bb2e80ae9&session_key=858594415a361e318af23dd1.1-635077092&sig=55f7e932f8e68a7dad6ae35af1877b45&uid=635077092\"", "_DefaultAppFacebook_session"=>"BAh7CToPc2Vzc2lvbl9pZCIlYzZjZGU5ZmJlNGU0NTM2ZjExNmQ1ZGQ5ZTc3ZjhiZDUiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA6EF9jc3JmX3Rva2VuIjFnZllGbGFVK0hMdVdZcDZaZjhJY3VJWVlZY2dEakc4VCtpM0dWTktSbFFRPSILbGF5b3V0IgxkZXNrdG9w--195b2d14ce7593502ec6d161906ceb0c38ed4219", "28aac256bbbe09dcae1eb7086ae1c326_ss"=>"0854c086618a5e075e2d9a866ce03f82"}
@facebook_cookies = Koala::Facebook::OAuth.new.get_user_info_from_cookie(cookies)
oauth_access_token = @facebook_cookies["access_token"]
graph = Koala::Facebook::GraphAPI.new(oauth_access_token)
fb_user = graph.get_object('me')

产生错误信息:

OpenSSL::SSL::SSLError: certificate verify failed
from /usr/lib/ruby/1.8/net/http.rb:586:in `connect'
from /usr/lib/ruby/1.8/net/http.rb:586:in `connect'
from /usr/lib/ruby/1.8/net/http.rb:553:in `do_start'
from /usr/lib/ruby/1.8/net/http.rb:542:in `start'
from /usr/lib/ruby/1.8/net/http.rb:1035:in `request'
from /usr/lib/ruby/1.8/net/http.rb:772:in `get'
from /usr/lib/ruby/gems/1.8/gems/faraday-0.7.4/lib/faraday/adapter/net_http.rb:49:in `call'
from /usr/lib/ruby/gems/1.8/gems/faraday-0.7.4/lib/faraday/request/url_encoded.rb:14:in `call'
from /usr/lib/ruby/gems/1.8/gems/faraday-0.7.4/lib/faraday/request/multipart.rb:13:in `call'
from /usr/lib/ruby/gems/1.8/gems/faraday-0.7.4/lib/faraday/connection.rb:203:in `run_request'
from /usr/lib/ruby/gems/1.8/gems/faraday-0.7.4/lib/faraday/connection.rb:85:in `get'
from /usr/lib/ruby/gems/1.8/gems/koala-1.2.0/lib/koala/http_service.rb:49:in `send'
from /usr/lib/ruby/gems/1.8/gems/koala-1.2.0/lib/koala/http_service.rb:49:in `make_request'
from /usr/lib/ruby/gems/1.8/gems/koala-1.2.0/lib/koala.rb:131:in `make_request'
from /usr/lib/ruby/gems/1.8/gems/koala-1.2.0/lib/koala.rb:57:in `api'
from /usr/lib/ruby/gems/1.8/gems/koala-1.2.0/lib/koala/graph_api.rb:215:in `graph_call'
from /usr/lib/ruby/gems/1.8/gems/koala-1.2.0/lib/koala/graph_api.rb:36:in `get_object'

很明显是SSL证书相关的东西,所以我尝试配置Koala:

Koala.http_service.http_options = {
:ssl => {
:ca_file => '/etc/ssl/certs',
:verify_mode => OpenSSL::SSL::VERIFY_PEER,
:verify => true
}
}

...并下载 http://curl.haxx.se/ca/cacert.pem/etc/ssl/certs 文件夹。虽然没有任何明显的区别。

相关的 gem 是:

faraday (0.7.4)
koala (1.2.0)
rails (2.3.5)
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]

我找到了 related SO posts但没有完美匹配。

最佳答案

我在 Rails 3.2、Ruby 1.9.3、Ubuntu 11.10 上遇到了同样的问题

除了证书文件现在是 ca-certificates.crt 之外,TenJack 的回答有效,所以:

Koala::HTTPService.http_options[:ssl] = {:ca_file => '/etc/ssl/certs/ca-certificates.crt'}

关于ruby-on-rails - Rails 2.3.x & 考拉 & Facebook : certificate verify failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7615750/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com