我正在尝试使用fog-google将图片上传到我的Google云存储空间。 我的代码如下所示:
config.paperclip_defaults = {
storage: :fog,
fog_host: "https://#{ENV.fetch('GOOGLE_STORAGE_BUCKET')}.storage.googleapis.com",
fog_credentials: {
google_storage_access_key_id: ENV.fetch('GOOGLE_STORAGE_ID'),
google_storage_secret_access_key: ENV.fetch('GOOGLE_STORAGE_SECRET'),
provider: 'Google' },
fog_directory: ENV.fetch('GOOGLE_STORAGE_BUCKET') }
但是,我总是得到这个错误:
Excon::Error::Socket: SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A (OpenSSL::SSL::SSLError)
似乎连接未成功建立。
以下是错误日志:
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/ssl_socket.rb:117:in `connect_nonblock'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/ssl_socket.rb:117:in `initialize'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/connection.rb:404:in `new'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/connection.rb:404:in `socket'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/connection.rb:101:in `request_call'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/middlewares/mock.rb:48:in `request_call'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/middlewares/instrumentor.rb:26:in `request_call'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/middlewares/base.rb:16:in `request_call'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/middlewares/base.rb:16:in `request_call'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/middlewares/base.rb:16:in `request_call'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/excon-0.59.0/lib/excon/connection.rb:250:in `request'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/fog-core-1.45.0/lib/fog/core/connection.rb:81:in `request'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/fog-xml-0.1.3/lib/fog/xml/connection.rb:9:in `request'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/fog-google-0.6.0/lib/fog/storage/google_xml/real.rb:103:in `request'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/fog-google-0.6.0/lib/fog/storage/google_xml/requests/head_object.rb:36:in `head_object'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/fog-google-0.6.0/lib/fog/storage/google_xml/models/files.rb:81:in `head'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/paperclip-5.1.0/lib/paperclip/storage/fog.rb:65:in `exists?'
答案 0 :(得分:0)
这是因为您尝试访问网址https并且无法在您的情况下验证ssl。
尝试添加OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
编辑 - 关注中间人攻击
此外,您可以通过添加ssl证书并执行以下步骤来验证您的应用程序
将https://curl.haxx.se/ca/cacert.pem下载到path_to_file \ cacert.pem中。确保将其另存为.pem文件,而不是文本文件。
设置环境变量:SSL_CERT_FILE = path_to_file\cacert.pem
重新启动所有ruby / rails应用程序并立即重试访问它。
答案 1 :(得分:0)
当我从Windows切换到Linux时,它可以正常工作。
答案 2 :(得分:0)
使用Windows Linux子系统。禁用IPV6对我来说是有效的(对于hyper-V)。