无法验证证书 - 请设置'ENV ['SSL_CERT_FILE'] = path_to_file'

Vee*_*Vee 8 ssl ruby-on-rails environment-variables amazon-s3 carrierwave

我有一个使用Carrierwave上传文件的Rails 4应用程序.安装Fog以将文件上传到Amazon 3后,我在上传文件时开始收到以下错误:

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).
Run Code Online (Sandbox Code Playgroud)

我很困惑,因为我已将"SSL_CERT_FILE"添加到我的环境路径(通过控制面板在用户和系统变量下),将其设置为c:/RailsInstaller/cacert.pem(并重新启动我的计算机).

当我的控制器在controllers/videos_controller中调用@ video.save时,错误就出现了:

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
Run Code Online (Sandbox Code Playgroud)

我在Windows 7上,使用ruby 1.9.3p484和RubyGems 2.2.2.有人可以帮我理解这个错误的原因以及如何解决它?

Jai*_*put 0

用于RVM修复SSL证书

RVMRuby Version Manager的最新版本包含一个实用程序,用于诊断和解决由过时的证书文件引起的错误。请参阅文章安装 Rails 以获取说明和建议。该RVM网站解释了如何安装 RVM。

如果您已安装3RVM,请尝试以下操作:

$ rvm -v
 # rvm 1.19.1 (stable)
$ rvm osx-ssl-certs status all
 # Certificates for
$ rvm osx-ssl-certs update all
 # Updating certificates
Run Code Online (Sandbox Code Playgroud)

有关该问题的更多信息,请参阅https://github.com/rvm/rvm/pull/1764上的讨论