【问题标题】:Excon::Error::Socket: SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A (OpenSSL::SSL::SSLError)Excon::Error::Socket: SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A (OpenSSL::SSL::SSLError)
【发布时间】:2017-11-16 19:29:38
【问题描述】:

我正在尝试使用雾谷歌将图像上传到我的谷歌云存储。 我的代码如下所示:

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?'

【问题讨论】:

  • 你有可能在代理后面吗?在许多情况下,代理会干扰可能导致此类问题的握手。

标签: ruby-on-rails paperclip google-cloud-storage google-cloud-endpoints fog


【解决方案1】:

这是因为您尝试访问网址 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 应用程序并立即重试访问它。

【讨论】:

  • 我认为这不是一个好主意。我确实想防止中间人攻击。
  • 那么您应该尝试验证您的应用程序 ssl
  • 我的应用程序已经使用了 excon 提供的 pem 文件
  • 另外,我尝试在调试模式下设置 verify_peer,同样的错误
【解决方案2】:

当我从 Windows 切换到 Linux 时它可以工作。

【讨论】:

    【解决方案3】:

    使用 Windows Linux 子系统。禁用 IPV6 对我有用(对于 hyper-V)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-06
      • 2017-06-03
      • 1970-01-01
      • 2013-08-21
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 1970-01-01
      相关资源
      最近更新 更多