2014-04-22 97 views
9

我在這裏看到很多答案,但他們都沒有工作。我使用omniauth-oauth2 gem與第三方客戶集成。SSL_connect SYSCALL返回= 5 errno = 0 state = SSLv2/v3讀取服務器hello A - Faraday :: Error :: ConnectionFailed

我使用的是安裝階段描述here但我總是收到此錯誤:

Authentication failure! failed_to_connect: Faraday::Error::ConnectionFailed, SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A 

Faraday::Error::ConnectionFailed (SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3  read server hello A): 
.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in `connect' 
.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:918:in `block in connect' 

我在config/initializers初始化是:

Rails.application.config.middleware.use OmniAuth::Builder do 
    client_id = 'my_client_id' 
    client_secret = 'secret' 

    ca_file = Rails.root.join('config', 'cacert.pem').to_s 

    ssl_options = {} 
    ssl_options[:ca_path] = '/usr/local/etc/openssl' 
    ssl_options[:ca_file] = ca_file 

    provider :my_partner_provider, client_id, client_secret, :client_options => {:ssl => ssl_options}, 
    setup: ->(env){ 
    req = Rack::Request.new(env) 
    site = "https://#{req.params.fetch('shop')}" 
    env['omniauth.strategy'].options[:client_options][:site] = site 
    } 
end 

我有和無SSL嘗試選項。

爲補充,這裏是我的籌碼:https://gist.github.com/cleytonmessias/11274209

我鍵入終端openssl s_client -showcerts -connect partnerurl.com:443 <<<OK並返回此:https://gist.github.com/cleytonmessias/11288646

有誰知道解決這個問題?

+0

你有沒有找到任何解決辦法? –

+0

我想說這是一個錯誤,但它可能不是來自Net :: HTTP。連接到Sharepoint服務時,我遇到了這個問題:wget也無法連接,而curl完全沒有問題。 – Michael

+0

但你解決了嗎?我仍然沒有找到任何東西。 – Cleyton

回答

4

我終於找到了最終答案:

由於@mislav,讓暗示改變ssl version

我不得不改變,因爲我的合作伙伴有使用asp.net構建的應用程序,並使用此版本的ssl。在http://mislav.uniqpath.com/2013/07/ruby-openssl/

更多,所以最終的代碼,因爲它遵循:

Rails.application.config.middleware.use OmniAuth::Builder do 
    client_id = 'my_client_id' 
    client_secret = 'secret' 

    ssl_options = {} 
    ssl_options[:version] = :TLSv1 

    ssl = {} 
    ssl[:ssl] = ssl_options 

    provider :partner, client_id, client_secret, 
    client_options: { connection_opts: ssl} , 
    setup: ->(env){ 
    req = Rack::Request.new(env) 
    token_url = "https://#{req.params.fetch('shop')}" 
    env['omniauth.strategy'].options[:client_options][:token_url] = token_url 
    } 
end 
相關問題