简体   繁体   中英

Google API using Signet, SSL Error

I am making a Ruby On Rails application and I am attempting to use the Google Plus API's for user sign in. To do this I am using Signet an OAuth helper library. I am looking at this code as an example of Signet with Google APIs.

Here is my code:

require "signet/oauth_2/client"
require "google/api_client"


oathClient = Signet::OAuth2::Client.new(
  :authorization_uri => "https://accounts.google.com/o/oauth2/auth",
  :token_credential_uri => "https://accounts.google.com/o/oauth2/token",
  :client_id => Rails.application.secrets.gapi_client_id,
  :client_secret => Rails.application.secrets.gapi_client_secret,
  :redirect_uri => Rails.application.secrets.gapi_redirect_uri,
  :scope => "https://www.googleapis.com/auth/plus.login")

gapi_client = Google::APIClient.new(
  :application_name => "Branches",
  :application_version => "0.0.1")

oathClient.code = request.body.read
oathClient.fetch_access_token!#Error on this line
gapi_client.authorization = oathClient

An error occurs on the second to last line:

oathClient.fetch_access_token!

This is the error:

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

I have done some research and it seams like this is caused by the lack of certificate information. However none of the solution's shown address this issue when dealing with Signet.



OS: Windows 8 x64
RoR version: 4.1.1
Signet Version: 0.5.1
Google API Client Version: 0.6.2

Looks related tohttps://github.com/googleapis/google-api-ruby-client/issues/235 , where the solutions were:

  1. update openssl
  2. if you're using a custom .pem file, set it with: export SSL_CERT_FILE=/path/to/custom/certificate/authority.pem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM