Amazon Cloudfront访问被拒绝

时间:2016-01-26 09:40:37

标签: c# amazon-s3 amazon-cloudfront

我创建了网络分发并检查了限制访问权限。这是screenshot

为了创建签名网址,我使用以下代码:

 var pathToKey = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                ManagerApiConfiguration.Config.Aws.AmazonCloudFrontSecretFilePath);

             var fileInfo = new FileInfo(pathToKey);

            var url = AmazonCloudFrontUrlSigner.GetCannedSignedURL(
                AmazonCloudFrontUrlSigner.Protocol.http,
                ManagerApiConfiguration.Config.Aws.AmazonCloudFrontResourcePath,
                fileInfo,
                key,
                ManagerApiConfiguration.Config.Aws.AmazonCloudFrontAccessKey,
                DateTime.Now.AddDays(1)
                );

正确填充所有变量。我查了一下,网址看起来像是:

  

http://XXXXXXXX.cloudfront.net/Themes/Case   ?覆盖/国际/ img1.jpg过期= 1453886647&安培;签名= KEpC4ej4f00ir5KMWmqYs3dD64hRQ1〜9609HvGk7KL8JjxNf207n99QXNtmSSXeu5JWH9wRqGfRzil76TH7oPl3NpTJwVhEcaty1E8mODrVIKaoFF-4SQ〜KhvPk4Z164UZhaEueroggtjHHfFbzByVQ7iDkU-qCXgl1JPjjonPvExIH3〜4QHh2GR1oiQDlZolgyA1Dts7JQglouKJ11-hhqRxZKD7FQMnE3adKGcnxvzd0Fx6x1Bnqy41nTGUPLdc〜将PRX〜ZgSLVQgO7EKJ7wMiK0ZUKRthhoRT1LqHFKotNyJdxFgXlrmENJpklt5Pezm6KM7Y〜E2Mo〜zpqBJJ7OYQ __&安培;密钥对-ID = APKAJEOHJXFJHBUONVPQ

但我收到错误:拒绝访问。 我也有保护政策:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::my_bucket_name/*"
        }
    ]
}

哪里出了问题。感谢。

PS。如果我取消选中限制访问权限,那么一切正常。

0 个答案:

没有答案