gpt4 book ai didi

ruby - Twilio 应用; twilio-ruby (3.4.2),SSL 错误

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

我遵循了 Twilio github page 上的示例代码它不起作用。在我的 Rails 控制台中,它看起来像这样:

irb(main):039:0> require 'twilio-ruby'
=> nil
irb(main):040:0* account_sid='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
=> "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
irb(main):041:0> auth_token='yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
=> "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
irb(main):042:0> client=Twilio::REST::Client.new account_sid, auth_token
=> <Twilio::REST::Client @account_sid=AC1322312300a752f6e84a8254535ecce5>
irb(main):043:0> client.account.sms.messages.create :from=>'16135551234', :to=>'16135551212', :body=>"Ada is fat"
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:678:in `connect'
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:678:in `block in connect'
from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:87:in `timeout'
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:678:in `connect'
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:626:in `start'
from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:1168:in `request'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/twilio-ruby-3.4.2/lib/twilio-ruby/rest/client.rb:214:in `connect_and_send'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/twilio-ruby-3.4.2/lib/twilio-ruby/rest/client.rb:138:in `block (2 levels) in <class:Client>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/twilio-ruby-3.4.2/lib/twilio-ruby/rest/list_resource.rb:73:in `create'
from (irb):43
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/commands/console.rb:44:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/commands/console.rb:8:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'irb(main):044:0>

我还需要做什么才能让twilio-ruby成功发送短信?我已经将这些号码和凭据用于来电,所以它们很好。

** 编辑 2011 年 12 月 24 日 ***我没有在我的 PC 上运行此代码,而是将其部署到 heroku.com。然后我没有 SSL 错误,并且能够拨出电话。我很疑惑。

最佳答案

这在从 3.5.0 开始的 twilio-ruby 版本中应该不是问题。它现在开箱即用。

对于 3.5.0 之前的 twilio-ruby 版本,没有与 gem 打包的 SSL CA 证书包。因此,“修复”此问题的唯一方法是在初始化时将您的客户端指向证书包:

client = Twilio::REST::Client.new sid, token, :ssl_ca_file => '/path/to/file'

或完全禁用 SSL 验证(在生产中不推荐):

client = Twilio::REST::Client.new sid, token, :ssl_verify_peer => false

关于ruby - Twilio 应用; twilio-ruby (3.4.2),SSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8583729/

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