问题描述
我有一个Rails 4应用程序使用Carrierwave上传文件。安装雾将文件上传到亚马逊3后,我开始在上传文件时,收到以下错误:
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).
我很困惑,因为我已经加入SSL_CERT_FILE我的环境路径(通过控制面板的用户和系统变量下),将其设置到C:/RailsInstaller/cacert.pem(并重新启动我的电脑)
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).
该错误就要到了,当我的控制器调用@ video.save在控制器/ videos_controller:
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
我在Windows 7中,使用红宝石1.9.3p484和RubyGems的2.2.2。有人可以帮我理解这个错误的原因以及如何解决它?
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?
推荐答案
使用RVM修复SSL证书
Use RVM to Fix SSL Certificates
RVM,Ruby的版本管理,最新版本包括一个实用程序来诊断和解决由于过时的证书文件中的错误。有关说明请参阅和建议的文章中安装滑轨。该RVM网站介绍如何安装RVM。
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.
如果您已经安装了3RVM,试试这个:
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
有关更多的问题,一看讨论 https://github.com/rvm/rvm/pull/1764
For more on the issue, see a discussion athttps://github.com/rvm/rvm/pull/1764
这篇关于无法验证证书 - 请设置“ENV ['SSL_CERT_FILE'] =文件路径”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!