簡體   English   中英

OpenSSL :: SSL :: SSLError與Homebrew OpenSSL握手失敗

[英]OpenSSL::SSL::SSLError Handshake Failure with Homebrew OpenSSL

我正在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'

我看了一些關於此的SO討論,尤其是這一討論使我相信OpenSSL找不到正確的cert.pem文件是一個問題。 我正在使用Homebrew,並且我的Homebrew OpenSSL安裝在/usr/local/bin 我認為OpenSSL的原始Mac版本位於/usr/bin

我按照建議將全局ENV變量SSL_CERT_FILE設置為Homebrew安裝的cert.pem文件的路徑- /usr/local/etc/openssl/cert.pem SSL_CERT_FILE cert.pem ,當我回顯該變量時,它設置正確,但是當我重新打開Ruby控制台並重試時,出現相同的錯誤。 關於我在做什么錯的想法? 我對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

那是問題嗎? 給定我的OpenSSL版本,我包含錯誤的cert.pem文件嗎?

state = SSLv3讀取服務器問候A:sslv3警報握手失敗

通常這不是證書損壞或丟失的問題,而是服務器不喜歡客戶端發送的內容,例如不受支持的SSL版本或客戶端沒有提供適當的密碼。 如果我嘗試使用SSL3.0而不是TLS1.0或更高版本進行連接,則會在此主機上收到此錯誤,因此請確保您不再使用SSL3.0。

如果這樣不能幫助捕獲流量的數據包,然后將其發布到cloudshark.org,以便可以了解流量的詳細信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM