我正在尝试使用SoundCloud SDK进行用户身份验证。用户点击“登录”后的第一条路线:
get "/login" do
client = Soundcloud.new(:client_id => 'MY_ID',
:client_secret => 'MY_SECRET',
:redirect_uri => 'http://localhost:9393/signed_in')
redirect client.authorize_url()
end
然后我有了重定向的下一个路线:
get "/signed_in" do
client = Soundcloud.new(:client_id => '16d6ada1a0cfc5009f7d59d203a13b2f',
:client_secret => '845df7d44dc4e359fedc8ed5944d29a5',
:redirect_uri => 'http://localhost:9393/signed_in')
code = params[:code]
access_token = client.exchange_token(:code => code)
end
我可以成功点击重定向网址并传回一段代码,但我收到Sinatra的以下错误:
/ signed_in中的OpenSSL :: SSL :: SSLError SSL_connect返回= 1 errno = 0状态= SSLv3读取服务器证书B:证书验证失败
我读过这些热门文章: http://railsapps.github.io/openssl-certificate-verify-failed.html
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
以及其他许多人
当我输入:
rvm osx-ssl-certs status all
我的结果是 /usr/local/etc/openssl/cert.pem的证书:最新。
我目前在Mac 10.6.8上使用ruby 2.1.1。关于这个主题我已经走了大约20个堆栈溢出问题,我无法解决这个问题。
答案 0 :(得分:0)
/usr/local/etc/openssl/certs/
让omniauth.rb看起来像这样:
options = {
scope: "email",
:prompt => "select_account",
access_type: 'offline',
:client_options => {
:ssl => {
:ca_file => "/usr/local/etc/openssl/certs/ca-bundle.crt",
:ca_path => "/usr/local/etc/openssl/certs"
}
}
}
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, Rails.application.secrets.client_id, Rails.application.secrets.client_secret, options
end
答案 1 :(得分:0)
有一个宝石可以解决此问题,请尝试将gem 'certified', '~> 1.0'
添加到您的Gemfile
。