OpenSSL :: SSL :: SSLError"证书验证失败"当使用Ruby Gem' cryptsy-api'

时间:2014-08-09 05:41:18

标签: ruby openssl ssl-certificate

我试图使用cryptsy-api gem,但似乎有某种SSL错误。这是我的irb会话中的输出:

首先我加载api:

$ irb
2.1.2 :001 > require 'cryptsy/api'
 => true

然后我设置了建立连接所需的两个变量(在本例中使用伪名称)

2.1.2 :002 > key = 'thisisasecretkeythisisasecretkeythisisa'
 => "thisisasecretkeythisisasecretkeythisisa"
2.1.2 :003 > secret = 'thisisasecretkeythisisasecretkeythisisasecretkeythisisasecretkeythisisasecretkey'
 => "thisisasecretkeythisisasecretkeythisisasecretkeythisisasecretkeythisisasecretkey"

现在我实例化一个新实例:

2.1.2 :004 > cryptsy = Cryptsy::API::Client.new(key, secret)
 => #<Cryptsy::API::Client:0x007fcf6b81aff0 @key="thisisasecretkeythisisasecretkeythisisa",     @secret="thisisasecretkeythisisasecretkeythisisasecretkeythisisasecretkeythisisasecretkey", @private_caller=nil>

这是我收到错误的地方。当我在实例上调用方法时,它会抛出此错误:

2.1.2 :005 > cryptsy.getinfo
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
  from /Users/caymanner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:920:in `connect'
  from /Users/caymanner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:920:in `block in connect'
  from /Users/caymanner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
  from /Users/caymanner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:920:in `connect'
  from /Users/caymanner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
  from /Users/caymanner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:852:in `start'
  from /Users/caymanner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:1369:in `request'
  from /Users/caymanner/.rvm/gems/ruby-2.1.2/gems/httparty-0.13.1/lib/httparty/request.rb:93:in `perform'
  from /Users/caymanner/.rvm/gems/ruby-2.1.2/gems/httparty-0.13.1/lib/httparty.rb:521:in `perform_request'
  from /Users/caymanner/.rvm/gems/ruby-2.1.2/gems/httparty-0.13.1/lib/httparty.rb:473:in `post'
  from /Users/caymanner/.rvm/gems/ruby-2.1.2/gems/cryptsy-api-0.1.4/lib/cryptsy/api.rb:36:in `execute_method'
  from /Users/caymanner/.rvm/gems/ruby-2.1.2/gems/cryptsy-api-0.1.4/lib/cryptsy/api.rb:204:in `call_private_api'
  from /Users/caymanner/.rvm/gems/ruby-2.1.2/gems/cryptsy-api-0.1.4/lib/cryptsy/api.rb:82:in `getinfo'
  from (irb):5
  from /Users/caymanner/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `<main>'
2.1.2 :006 >

为什么会这样?我忘记加载其他宝石了吗?

1 个答案:

答案 0 :(得分:0)

http://CascadiaRuby.com会议上和@thagomizer_rb谈过,他被这样的臭虫咬了半打。显然Mac附带的OpenSSL库已经过时了。

修复是安装更新版本的OpenSSL。我的解决方案是使用brew:

$ brew update&amp;&amp; brew install openssl