8

I have a Rails 4 application that uses Carrierwave to upload files. After installing Fog to upload files to Amazon 3, I started getting the following error when uploading files:

Excon::Errors::SocketError in VideosController#create

Unable to verify certificate, please set `Excon.defaults[:ssl_ca_path] = path_to_certs`, `ENV['SSL_CERT_DIR'] = path_to_certs`, `Excon.defaults[:ssl_ca_file] = path_to_file`, `ENV['SSL_CERT_FILE'] = path_to_file`, `Excon.defaults[:ssl_verify_callback] = callback` (see OpenSSL::SSL::SSLContext#verify_callback), or `Excon.defaults[:ssl_verify_peer] = false` (less secure).

I'm confused because I have added 'SSL_CERT_FILE' to my environment paths (under both user and system variables via the Control Panel), setting it to c:/RailsInstaller/cacert.pem (and restarted my computer).

The error is coming up when my controller calls @video.save in controllers/videos_controller:

class SessionsController < ApplicationController

def create
  @video = Video.new(video_params)
  if @video.save
    redirect_to videos_path, notice: "Video has been uploaded."
  else
    render "new"
  end
end


private

def video_params
  params.require(:video).permit(:name, :attachment) 
end

end

I'm on Windows 7, using ruby 1.9.3p484 and RubyGems 2.2.2. Can somebody help me understand the cause of this error and how to fix it?

Vee
  • 1,821
  • 3
  • 36
  • 60
  • Did you ever find the answer? – Jeff Jan 20 '15 at 22:41
  • @jeff, I think I ended up using the 'carrierwave-aws' gem which provides file uploading capabilities to Amazon S3 as well as Amazon aws-sdk gem functionality. This allowed me to skip Fog (which I think was causing the error but can't remember exactly). I don't think I ever figured out how to resolve the certificate error. – Vee Jan 21 '15 at 04:44
  • I think you need to define the ENV to your server via the console. In heroku you can do `heroku config:set SSL_CERT_DIR=frfrboxc88b1bd SSL_CERT_FILE=c5707cff6dd5b11a06` – Antoine Apr 20 '15 at 15:30
  • 1
    I had a similar problem a while back but on heroku and solved it with information in https://github.com/excon/excon/issues/239. What solved it for me was to install the `ca-bundle.crt` on heroku and run `heroku config:set SSL_CERT_FILE=/app/lib/ca-bundle.crt` – Derek Apr 26 '15 at 04:12
  • Had a problem with excon errors in the past deailing with fog uploaded and open-ssl ended up being the issue. I had to do this to fix brew update ; brew uninstall openssl ; brew install openssl – MilesStanfield Aug 24 '15 at 01:37

1 Answers1

0

Use RVM to Fix SSL Certificates

Recent versions of RVM, the Ruby Version Manager, include a utility to diagnose and resolve errors caused by outdated certificate files. See the article Installing Rails for instructions and advice. The RVM website explains how to install RVM.

If you have installed 3RVM, try this:

$ rvm -v
 # rvm 1.19.1 (stable)
$ rvm osx-ssl-certs status all
 # Certificates for
$ rvm osx-ssl-certs update all
 # Updating certificates

For more on the issue, see a discussion at https://github.com/rvm/rvm/pull/1764

Jai Chauhan
  • 4,035
  • 3
  • 36
  • 62