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

时间:2022-06-13 10:56:37

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:

我有一个使用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).

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).

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

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

当我的控制器在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

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?

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

1 个解决方案

#1


0  

Use RVM to Fix SSL Certificates

使用RVM修复SSL证书

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.

最新版本的RVM(Ruby版本管理器)包含一个实用程序,用于诊断和解决由过时的证书文件导致的错误。有关说明和建议,请参阅文章安装Rails。 RVM网站介绍了如何安装RVM。

If you have installed 3RVM, try this:

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

$ 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://github.com/rvm/rvm/pull/1764上的讨论

#1


0  

Use RVM to Fix SSL Certificates

使用RVM修复SSL证书

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.

最新版本的RVM(Ruby版本管理器)包含一个实用程序,用于诊断和解决由过时的证书文件导致的错误。有关说明和建议,请参阅文章安装Rails。 RVM网站介绍了如何安装RVM。

If you have installed 3RVM, try this:

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

$ 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://github.com/rvm/rvm/pull/1764上的讨论