Laravel上的Amazon S3 ERR_INSECURE_RESPONSE [英] Amazon S3 ERR_INSECURE_RESPONSE on Laravel

查看:87
本文介绍了Laravel上的Amazon S3 ERR_INSECURE_RESPONSE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在子域sub.example.com上使用Laravel框架,试图为我网站上的所有图片实现与Amazon S3的连接.

这是我的存储桶(bucket-1)的政策

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

这是我的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>

我为我的用户授予了所有权限,而为Everyone仅授予了list.

为什么我上传图片时该图片未显示在我的网站上(net::ERR_INSECURE_RESPONSE)?

如果我导航到图片的网址(https://s3.eu-west-1.amazonaws.com/bucket-1/...),Chrome浏览器将显示警告页面,并显示消息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

让我更加困惑的是,如果我将相同的链接复制粘贴到另一个选项卡上,那么我可以看到图片而没有任何问题.

解决方案

您正在使用s3.eu-west-1.amazonaws.com,但是您应该使用s3-eu-west-1.amazonaws.com ...您希望在"s3"之后使用破折号而不是点. /p>

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

S3中的不同区域的约定会有所不同,具体取决于年龄.您所做的操作在eu-central-1中是有效的,它可以双向工作,但在eu-west-1中无效.

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.

解决方案

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.

这篇关于Laravel上的Amazon S3 ERR_INSECURE_RESPONSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆