Unable to verify certificate - please set 'ENV['SSL_CERT_FILE'] = path_to_file'

余生长醉 提交于 2020-01-03 08:24:27

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/25701632/unable-to-verify-certificate-please-set-envssl-cert-file-path-to-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!