我试图在MacOSX上的Ruby中提出一个API请求。
当我尝试这样的东西时:
RestClient.get("https://api.foursquare.com/v2/venues/explore?near=NYC&query=McDonalds")我得到这个(当它是http时也是这样):
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server hello A: sslv3 alert handshake failure
from /Users/sasha/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:920:in `connect'(如果我尝试(open("https://...")),我会得到以下内容:
OpenURI::HTTPError: 400 Bad Request
from /Users/sasha/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/open-uri.rb:353:in `open_http'我看了一些这样的讨论,尤其是this one,让我相信OpenSSL找不到合适的cert.pem文件是个问题。我正在使用Homebrew,我的Homebrew OpenSSL安装在/usr/local/bin中。我认为,最初的Mac版本的OpenSSL是在/usr/bin。
我按照建议,将全局ENV变量SSL_CERT_FILE设置为cert.pem文件的路径,这是由Homebrew - /usr/local/etc/openssl/cert.pem安装的,当我响应该变量时,它被正确设置,但是当我重新打开一个cert.pem控制台并再次尝试时,我会得到相同的错误。关于我做错了什么的想法?我对OpenSSL不太了解,而且我完全被这一条搞糊涂了,因为它似乎找到了我的证书。
编辑
当我运行which openssl时,它显示的是Mac版本-- /usr/bin/openssl。考虑到Homebrew的安装说明,这是有意义的:
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.
The OpenSSL provided by OS X is too old for some software.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include这就是问题所在吗?考虑到我的cert.pem版本,我是不是包含了错误的OpenSSL文件?
发布于 2014-10-18 18:36:08
state=SSLv3读取服务器hello A: sslv3警报握手失败
这通常不是一个坏证书或丢失证书的问题,而是服务器不喜欢客户端发送的内容,比如不支持的SSL版本,或者客户端提供的不合适的密码。如果我试图连接SSL3.0而不是TLS1.0或更高版本,就会在这个主机上产生这个错误,所以请确保不再使用SSL3.0。
如果这无助于对通信量进行数据包捕获,并将其发布到cloudshark.org,以便您可以查看流量详细信息。
https://stackoverflow.com/questions/26442090
复制相似问题