Amazon S3 ERR_INSECURE_RESPONSE on Laravel

匆匆过客 提交于 2019-12-04 06:42:15

问题


I'm using Laravel framework on my subdomain sub.example.com trying to implement the connection with Amazon S3 for all the pictures of my website.

This is my Policy for my bucket (bucket-1)

{
    "Id": "Policy************",
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt***********",
            "Action": [
                "s3:GetObject"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::bucket-1/*",
            "Principal": "*"
        }
    ]
}

This is my CORS

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>DELETE</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <ExposeHeader>ETag</ExposeHeader>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

I granteed all permissions for my user and only list for Everyone.

Why when I upload a picture, that picture is not shown on my website (net::ERR_INSECURE_RESPONSE)?

If I navigate to the url of the picture (https://s3.eu-west-1.amazonaws.com/bucket-1/...) Chrome shows a warning page with the message Your connection is not private

s3.eu-west-1.amazonaws.com. NET::ERR_CERT_COMMON_NAME_INVALID
Subject: *.s3-eu-west-1.amazonaws.com
Issuer: DigiCert SHA2 High Assurance Server CA

The thing that makes me even more baffled is that if I copy paste the same link on another tab, I can see the picture without any problem.


回答1:


You're using s3.eu-west-1.amazonaws.com, but you should be using s3-eu-west-1.amazonaws.com... you want a dash instead of a dot after "s3."

http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

Different regions in S3 have variations in their conventions, depending on age. What you did would have been valid in eu-central-1, which works both ways, but not in eu-west-1.



来源:https://stackoverflow.com/questions/34589296/amazon-s3-err-insecure-response-on-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!