简体   繁体   English

如何为Amazon S3存储桶配置SSL

[英]How to Configure SSL for Amazon S3 bucket

I am using an Amazon S3 bucket for uploading and downloading of data using my .NET application. 我正在使用Amazon S3存储桶使用我的.NET应用程序上传和下载数据。 Now my question is: I want to access my S3 bucket using SSL. 现在我的问题是:我想使用SSL访问我的S3存储桶。 Is it possible to implement SSL for an Amazon s3 bucket? 是否可以为Amazon s3存储桶实施SSL?

You can access your files via SSL like this: 您可以通过SSL访问您的文件,如下所示:

https://s3.amazonaws.com/bucket_name/images/logo.gif

If you use a custom domain for your bucket, you can use S3 and CloudFront together with your own SSL certificate (or generate a free one via Amazon Certificate Manager): http://aws.amazon.com/cloudfront/custom-ssl-domains/ 如果您为存储桶使用自定义域,则可以将S3和CloudFront与您自己的SSL证书一起使用(或通过Amazon Certificate Manager生成免费证书): http//aws.amazon.com/cloudfront/custom-ssl-域/

Custom domain SSL certs were just added today for $600/cert/month. 现在只需600美元/证书/月即可添加自定义域SSL证书。 Sign up for your invite below: http://aws.amazon.com/cloudfront/custom-ssl-domains/ 在下面注册您的邀请: http//aws.amazon.com/cloudfront/custom-ssl-domains/

Update : SNI customer provided certs are now available for no additional charge. 更新 :SNI客户提供的证书现在可以免费使用。 Much cheaper than $600/mo, and with XP nearly killed off, it should work well for most use cases. 比美元600美元便宜得多,而XP几乎被淘汰,它应该适用于大多数用例。

@skalee AWS has a mechanism for achieving what the poster asks for, "implement SSL for an Amazon s3 bucket", it's called CloudFront . @skalee AWS有一种机制可以实现海报要求的“为亚马逊s3桶实施SSL”,它被称为CloudFront I'm reading "implement" as "use my SSL certs," not "just put an S on the HTTP URL which I'm sure the OP could have surmised. 我正在阅读“实施”作为“使用我的SSL证书”,而不是“只是在HTTP URL上放置一个我确信OP可以推测的。

Since CloudFront costs exactly the same as S3 ($0.12/GB), but has a ton of additional features around SSL AND allows you to add your own SNI cert at no additional cost, it's the obvious fix for "implementing SSL" on your domain. 由于CloudFront的成本与S3完全相同(0.12美元/ GB),但是围绕SSL提供了大量附加功能,并且允许您无需额外成本添加自己的SNI证书,这是在您的域上“实施SSL”的明显修复。

I found you can do this easily via the Cloud Flare service. 我发现您可以通过Cloud Flare服务轻松完成此操作。

Set up a bucket, enable webhosting on the bucket and point the desired CNAME to that endpoint via Cloudflare... and pay for the service of course... but $5-$20 VS $600 is much easier to stomach. 设置一个存储桶,在存储桶上启用虚拟主机并通过Cloudflare将所需的CNAME指向该端点......当然要支付服务费用......但是$ 5 $ 20 VS $ 600更容易忍受。

Full detail here: https://www.engaging.io/easy-way-to-configure-ssl-for-amazon-s3-bucket-via-cloudflare/ 详细信息请访问: https//www.engaging.io/easy-way-to-configure-ssl-for-amazon-s3-bucket-via-cloudflare/

If you really need it, consider redirections. 如果您真的需要它,请考虑重定向。

For example, on request to assets.my-domain.example.com/path/to/file you could perform a 301 or 302 redirection to my-bucket-name.s3.amazonaws.com/path/to/file or s3.amazonaws.com/my-bucket-name/path/to/file (please remember that in the first case my-bucket-name cannot contain any dots, otherwise it won't match *.s3.amazonaws.com, s3.amazonaws.com stated in S3 certificate). 例如,根据对assets.my-domain.example.com/path/to/file请求,您可以执行301或302重定向到my-bucket-name.s3.amazonaws.com/path/to/files3.amazonaws.com/my-bucket-name/path/to/file (请记住,在第一种情况下, my-bucket-name不能包含任何点,否则它将不匹配*.s3.amazonaws.com, s3.amazonaws.com在S3证书中说明。

Not tested, but I believe it would work. 没有经过测试,但我相信它会起作用。 I see few gotchas, however. 然而,我看到了很少的陷阱。

The first one is pretty obvious, an additional request to get this redirection. 第一个很明显,另外一个获得此重定向的请求。 And I doubt you could use redirection server provided by your domain name registrar — you'd have to upload proper certificate there somehow — so you have to use your own server for this. 我怀疑你可以使用你的域名注册商提供的重定向服务器 - 你必须以某种方式上传正确的证书 - 所以你必须使用你自己的服务器。

The second one is that you can have urls with your domain name in page source code, but when for example user opens the pic in separate tab, then address bar will display the target url. 第二个是您可以在页面源代码中使用您的域名网址,但是当用户在单独的选项卡中打开图片时,地址栏将显示目标网址。

It is not possible directly with S3, but you can create a Cloud Front distribution from you bucket. 无法直接使用S3,但您可以从您的存储桶创建Cloud Front分发。 Then go to certificate manager and request a certificate. 然后转到证书管理器并申请证书。 Amazon gives them for free. 亚马逊免费提供给他们。 Ones you have successfully confirmed the certification, assign it to your Cloud Front distribution. 您已成功确认认证,将其分配给您的Cloud Front分发。 Also remember to set the rule to re-direct http to https. 另请记住将规则设置为将http重定向到https。

I'm hosting couple of static websites on Amazon S3, like my personal website to which I have assigned the SSL certificate as they have the Cloud Front distribution. 我在Amazon S3上托管几个静态网站,就像我的个人网站,我已经分配了SSL证书,因为他们有Cloud Front发行版。

As mentioned before, you cannot create free certificates for S3 buckets. 如前所述,您无法为S3存储桶创建免费证书。 However, you can create Cloud Front distribution and then assign the certificate for the Cloud Front instead. 但是,您可以创建Cloud Front分发,然后为Cloud Front分配证书。 You request the certificate for your domain and then just assign it to the Cloud Front distribution in the Cloud Front settings. 您为域申请证书,然后将其分配到Cloud Front设置中的Cloud Front分配。 I've used this method to serve static websites via SSL as well as serve static files. 我已经使用这种方法通过SSL服务静态网站以及提供静态文件。

For static website creation Amazon is the go to place. 对于静态网站创建,亚马逊就是最佳选择。 It is really affordable to get a static website with SSL. 获得一个带有SSL的静态网站真的很实惠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM