Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 291
Atsuhiro Teshima Avatar asked Mar 23 '26 09:03

Atsuhiro Teshima


1 Answers

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.

like image 55
Frederick Cheung Avatar answered Mar 24 '26 23:03

Frederick Cheung



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!