asset_sync gem error: rake assets:precompile fails : does not match the server certificate (OpenSSL::SSL::SSLError)

StackOverflow https://stackoverflow.com/questions/20861598

Question

asset_sync gem error :(

The first error I started out with was related to the unf gem, so I added gem "unf", "~> 0.1.3" to my gemfile and tried things again. No luck :( After more research I may have an issue with another setting related to my aws bucket. My dns is hosted via route53 and I wanted to use a custom domain to serve my assets. This means my bucket will look like assets.domain.com instead of just a plain name. when I attempt to run rake assets:precompile it aborts with the error rake aborted! hostname "assets.domain.com.s3-us-west-1.amazonaws.com" does not match the server certificate (OpenSSL::SSL::SSLError)" however that error appears to be wrong. In order to use your own sub domain i.e. assets. I read that the bucket must be setup as a static website. This means the url looks like assets.domain.com.s3-website-us-west-1.amazonaws.com which does not seem to match the error code.

am I missing a setting here? maybe I am crazy... thank you for your help.

my production.rb settings

# 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

my current initializer file:

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
Was it helpful?

Solution

Fixed by adding: 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

Reference issues: https://github.com/rumblelabs/asset_sync/issues/236, https://github.com/fog/fog/issues/2357

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top