karlfreeman/middleman-sync

Sync Fails If S3 Bucket Name Contains A Period

Closed this issue · 4 comments

I appreciate this is an Asset Sync issue, but it will effect people using S3 buckets to host static sites with custom domain names.

Amazon requires that if you are setting up a bucket for a static site, it is named off your domain, including sub domains:

example.com
www.example.com

However it seems that Asset Sync and therefore Middleman Sync will fail if the bucket name contains a period with the following error:

/Users/me/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/openssl/ssl-internal.rb:121:in `post_connection_check': hostname does not match the server certificate (OpenSSL::SSL::SSLError) (Excon::Errors::SocketError)

It seems SSL related - something to do with Amazon's SSL certificate not allowing for subdomains.

This would appear to mean that using Middleman Sync is no longer an option if the site is hosted on S3 with a custom domain name.

This would appear to be a relatively recent change. and hopefully I am jumping to the wrong conclusion.

For anyone encountering this issue and needing a quick fix, S3 Sync has no issues with periods.

Yep, seeing the same issue here. However this is a known issue for (asset_sync)[https://github.com/rumblelabs/asset_sync] — check out the docs.

This is a totally valid error that comes up regularly with S3. Basically, wildcard certificates are only valid for one level of the domain name and S3 uses lots of levels when the bucket name has periods so the wildcard cert doesn't match.

However, although this is a valid SSL error, it's imperative that anything using S3 can work around this.

The wiki on asset sync specifies you can use a different URL to do this. How do we configure this in middleman-sync?

From the docs:

config.action_controller.asset_host = "//s3.amazonaws.com/#{ENV['FOG_DIRECTORY']}"

Work around is to just add the following to config.rb

Fog.credentials = { :path_style => true }

As described here: #29