ruby-on-rails - asset_sync gem 错误:rake assets:precompile 失败:与服务器证书不匹配(OpenSSL::SSL::SSLError)

标签 ruby-on-rails amazon-web-services amazon-s3 asset-sync

asset_sync gem 错误:(

我开始遇到的第一个错误与 unf gem 相关,因此我将 gem "unf", "~> 0.1.3" 添加到我的 gemfile 中并再次尝试。不走运 :( 经过更多研究后,我可能对与我的 aws 存储桶相关的另一个设置有问题。我的 dns 是通过 route53 托管的,我想使用自定义域来服务我的 Assets 。这意味着我的存储桶看起来像 assets.domain.com 而不仅仅是一个简单的名称。当我尝试运行 rake assets:precompile 时,它会中止并显示错误 rake aborted! 主机名“assets.domain.com.s3-us-west-1.amazonaws.com”与服务器证书不匹配 (OpenSSL::SSL::SSLError)" 但是该错误似乎是错误的。按顺序使用您自己的子域,即 Assets 。我读到存储桶必须设置为静态网站。这意味着 url 看起来像 assets.domain.com.s3-website-us-west-1.amazonaws.com 似乎与错误代码不匹配。

我在这里缺少设置吗?也许我疯了...谢谢你的帮助。

我的 production.rb 设置

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
AssetSync.config.run_on_precompile = true
config.action_controller.asset_host = "http://assets.domain.com"
config.assets.prefix = "/data"

config.assets.enabled = true
config.assets.compile = true
config.assets.initialize_on_precompile = true

# Generate digests for assets URLs.
config.assets.digest = true

我当前的初始化文件:

if defined?(AssetSync)
  AssetSync.configure do |config|
    config.fog_provider = 'AWS'
    config.aws_access_key_id = ENV['MY_S3_ID']
    config.aws_secret_access_key = ENV['MY_S3_SECRET']
    # To use AWS reduced redundancy storage.
    # config.aws_reduced_redundancy = true
    config.fog_directory = ENV['MY_S3_BUCKET']

    # Invalidate a file on a cdn after uploading files
    # config.cdn_distribution_id = "12345"
    # config.invalidate = ['file1.js']

    # Increase upload performance by configuring your region
    config.fog_region = ENV['MY_S3_ENDPOINT']
    #
    # Don't delete files from the store
    # config.existing_remote_files = "keep"
    #
    # Automatically replace files with their equivalent gzip compressed version
    # config.gzip_compression = true
    #
    # Use the Rails generated 'manifest.yml' file to produce the list of files to
    # upload instead of searching the assets directory.
    # config.manifest = true
    #
    # Fail silently.  Useful for environments such as Heroku
    # config.fail_silently = true
  end
end

最佳答案

通过添加修复:Fog.credentials = { path_style: true }

if defined?(AssetSync)
  AssetSync.configure do |config|
    config.fog_provider = 'AWS'
    config.aws_access_key_id = ENV['MY_S3_ID']
    config.aws_secret_access_key = ENV['MY_S3_SECRET']
    # To use AWS reduced redundancy storage.
    # config.aws_reduced_redundancy = true
    config.fog_directory = ENV['MY_S3_BUCKET']

    # Invalidate a file on a cdn after uploading files
    # config.cdn_distribution_id = "12345"
    # config.invalidate = ['file1.js']

    Fog.credentials = { path_style: true }

    # Increase upload performance by configuring your region
    config.fog_region = ENV['MY_S3_ENDPOINT']
    #
    # Don't delete files from the store
    # config.existing_remote_files = "keep"
    #
    # Automatically replace files with their equivalent gzip compressed version
    # config.gzip_compression = true
    #
    # Use the Rails generated 'manifest.yml' file to produce the list of files to
    # upload instead of searching the assets directory.
    # config.manifest = true
    #
    # Fail silently.  Useful for environments such as Heroku
    # config.fail_silently = true
  end
end

引用问题:https://github.com/rumblelabs/asset_sync/issues/236 , https://github.com/fog/fog/issues/2357

关于ruby-on-rails - asset_sync gem 错误:rake assets:precompile 失败:与服务器证书不匹配(OpenSSL::SSL::SSLError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20861598/

相关文章:

html - 单击按钮时图像缩放

amazon-web-services - S3 和 EMR 数据局部性

ruby-on-rails - 在 Rails 中处理多个根路径和范围

ios - AWS Dynamodb测试使用swift 3报错

ruby-on-rails - 自定义 Rails 环境,设计提示 key

node.js - AWS Lambda 函数在完成请求之前退出

video - 如何在网站上提供不同格式的视频流选项

ruby-on-rails - CarrierWave 与 Cloudfront 生成错误的 URL

javascript - 设置 Flash 通知超时

ruby-on-rails - 如何使用 faker gem 生成假的食物名称?