Ruby RestClient Openssl错误OS X.

时间:2016-02-04 11:29:58

标签: ruby-on-rails ruby google-api openssl

我需要帮助解决openssl问题。 OS X 10.11.1

which openssl
/usr/local/bin/openssl

openssl version
OpenSSL 1.0.2f  28 Jan 2016

rvm version
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

gem -v
2.5.2

bundle show | grep rest
  * rest-client (1.8.0)

所以,正如你所看到的,一切都是最新的。 但我仍然得到错误:

RestClient.get('https://www.googleapis.com')
RestClient::SSLCertificateNotVerified: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

但是github上的https工作得很好:

RestClient.get('https://github.com').code
 => 200 

我已经读过了 http://railsapps.github.io/openssl-certificate-verify-failed.html

没有任何帮助。它有什么问题?

1 个答案:

答案 0 :(得分:0)

正如Eric platon指出的那样google不再支持SSL v3.0了,但是对于mac和ruby,rvm和openssl,问题是即使你链接openssl而你正在使用最后一个openssl,ruby是针对系统编译的OpenSSL的, 所以请试试这个:

rvm reinstall ruby-X.Y.Z --with-openssl-dir=`brew --prefix openssl`

然后它应该工作,

irb(main):001:0> RestClient.get('https://www.googleapis.com')
RestClient::NotFound: 404 Not Found

并且请将brew使用brew更新到最新版本,这对我来说适用于版本:

╭─ ~  2.4.0@learn  SBCL 1.3.16 
╰─ brew --prefix openssl                                                                                                255 ↵  06:57 Dur  3371  16:34:01
/usr/local/opt/openssl
╭─ ~  2.4.0@learn  SBCL 1.3.16 
╰─ /usr/local/opt/openssl/bin/openssl version                                                                                           ✓  3373  17:05:45
OpenSSL 1.0.2k  26 Jan 2017
相关问题