1

I want to let users access their own Google Drive storage on my application. I have followed Google's instructions on their quick-start website, but I keep getting this error:

    C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/net/http.rb:923:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::SSLError)
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/net/http.rb:923:in `block in connect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/timeout.rb:73:in `timeout'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/net/http.rb:923:in `connect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/net/http.rb:852:in `start'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/net/http.rb:1375:in `request'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:82:in `perform_request'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:40:in `block in call'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:87:in `with_net_http_connection'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:32:in `call'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/faraday-0.9.2/lib/faraday/request/url_encoded.rb:15:in `call'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/faraday-0.9.2/lib/faraday/rack_builder.rb:139:in `build_response'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/faraday-0.9.2/lib/faraday/connection.rb:377:in `run_request'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/faraday-0.9.2/lib/faraday/connection.rb:177:in `post'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/signet-0.7.3/lib/signet/oauth_2/client.rb:960:in `fetch_access_token'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/signet-0.7.3/lib/signet/oauth_2/client.rb:998:in `fetch_access_token!'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/googleauth-0.5.1/lib/googleauth/signet.rb:69:in `fetch_access_token!'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/googleauth-0.5.1/lib/googleauth/user_authorizer.rb:179:in `get_credentials_from_code'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/googleauth-0.5.1/lib/googleauth/user_authorizer.rb:201:in `get_and_store_credentials_from_code'
        from quickstart.rb:36:in `authorize'
        from quickstart.rb:45:in `<main>'

I have tried downloading the certificate from http://curl.haxx.se/ca/cacert.pem and adding it to my system environments as SSL_CERT_FILE, but I still get the same error. Additionally, I get the same result when I update to RubyGem 2.6.7.

I also realized that the 'drive-ruby-quickstart.yaml' file created by 'quickstart.rb' is blank. Even when I did manage to properly store 'drive-ruby-quickstart.yaml' on Linux, Fedora 23, it led me to this:

/home/username/.gem/ruby/gems/google-api-client-0.9.19/lib/google/apis/core/http_command.rb:208:in `check_status': Unauthorized (Google::Apis::AuthorizationError)

I have been on this for weeks and still can't solve it. Please help.

I am mainly testing on Windows 10, and my RubyGem version is 2.6.7. I've tried Ruby versions 2.2.3 and 2.3.1, and Rails 5.0.0.1.

jacefarm
  • 6,747
  • 6
  • 36
  • 46
  • 2
    Turns out in order to solve this issue, all I had to do was download the cacerts.pem from this link (https://github.com/google/google-api-ruby-client/blob/master/lib/cacerts.pem) and set it in my system's environment variables SSL_CERT_FILE and done! I followed the recommendation made by sqrrrl from this thread (https://github.com/google/google-api-ruby-client/issues/235). It had something to do with the cacerts.pem file containing valid roots for Google – user7100767 Nov 02 '16 at 17:23
  • A bit more info for those facing the same problem, I followed this code structure (https://developers.google.com/glass/develop/mirror/authorization#authenticate_the_user) instead of the [quick-start website](https://developers.google.com/drive/v3/web/quickstart/ruby) – user7100767 Nov 02 '16 at 17:32
  • I'd recommend that you write an answer to your question with what solved the issue for your (getting google's cacerts.pem file) and flag it as answered. That way others who were able to solver their issue based on that answer can vote it up - like me :) – Saca Nov 06 '16 at 17:07

0 Answers0