Atsuhiro Teshima
Atsuhiro Teshima

Reputation: 1508

When the protocol is https, Amazon S3 assets won't load, - Rails, Heroku

I set up asset_sync gem on heroku, following this URL: https://github.com/rumblelabs/asset_sync

The settings are working and I uploaded all the static assets at S3.

The problem is, when I open page through https protocol, can't access any of the assets, because the browser returns "This Connection is Untrusted". (same with Chrome & Firefox).

Every assets will be able to use after I admit access to s3 assets url. https://myapp.asset.s3.amazonaws.com/assets

Anyone had same problem? how to fix this problem?

Upvotes: 3

Views: 1874

Answers (1)

Frederick Cheung
Frederick Cheung

Reputation: 84132

The SSL certificate for s3 is a wildcard certificate, i.e. it is for *.s3.amazonaws.com. However a lot of certificate checking libraries define this to cover foo.s3.amazonaws.com but not foo.bar.amazonaws.com: wildcard certificates only go one level down.

The simplest solution is to pick a bucket name with no dots in it, e.g. myapp-assets.

Another solution is to access the files as https://s3.amazonaws.com/myapp.asset/assets/.... I believe you'd have to set config.assets.prefix to tell rails that the assets aren't in the normal location relative to the asset host.

Upvotes: 6

Related Questions