简体   繁体   English

使用预签名 URL“SignatureDoesNotMatch”获取 AWS S3 Object

[英]Fetching AWS S3 Object using Presigned URL "SignatureDoesNotMatch"

I created a bucket in the region of Ireland, and blocked all public access on it.我在爱尔兰地区创建了一个存储桶,并阻止了对它的所有公共访问。 Moreover, I created a script to generate a presigned URL to get the object. For some reason, I always get a SignatureDoesNotMatch error.此外,我创建了一个脚本来生成预签名的 URL 以获取 object。出于某种原因,我总是收到 SignatureDoesNotMatch 错误。 I am unable to understand the reason behind it.我无法理解其背后的原因。 below is my code:下面是我的代码:

let getPresignedUrl = async () => {
    const AWS = require('aws-sdk');
    const s3 = new AWS.S3({apiVersion: '2006-03-01', region: 'eu-west-1'});

    console.log(`Starting...`);

    const params = {Bucket: 'mybucket', Key: 'potato.jpeg', Expires: 300};
    const url = await s3.getSignedUrlPromise('getObject', params);
    console.log('The URL is', url); // expires in 60 
};

getPresignedUrl();

This is the message I am receiving这是我收到的消息

<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
<AWSAccessKeyId>key</AWSAccessKeyId>
<StringToSign>GET 1603525258 /mybucket/potato.jpeg</StringToSign>
</Error>

Try modifying this:尝试修改这个:

const s3 = new AWS.S3({apiVersion: '2006-03-01', region: 'eu-west-1'});

To this:对此:

const s3 = new AWS.S3({apiVersion: '2006-03-01', region: 'eu-west-1', signatureVersion: 'v4'});

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

相关问题 AWS Lambda 使用调用的凭证为 S3 创建预签名的 URL - AWS Lambda create presigned URL for S3 using invoked credentials 如何使用预签名的 URL 以及 s3 aws-sdk-ruby v3 中的标签上传 object - How to upload an object using presigned URL along with tags in s3 aws-sdk-ruby v3 带有星号的 AWS S3 预签名 url 问题 - AWS S3 presigned url issue with asterisk 如何使用 golang aws sdk v2 获取未预签名的 s3 object url 的简单示例 - Simple Example of how to get the un-presigned s3 object url using the golang aws sdk v2 AWS Java SDK 2.0 S3 预签名 URL 公共 object 访问 - AWS Java SDK 2.0 S3 presigned URL public object access 处理 aws s3 预签名 URL 过期日期的最佳实践 - Best practice to handle aws s3 presigned URL expiration date AWS S3 无法使用预签名 URL 检索文档:无效日期(应该是纪元以来的秒数) - AWS S3 Failure to Retrieve Document Using PreSigned URL : Invalid date (should be seconds since epoch) 测试 AWS S3 Presigned Url 返回 403 Forbidden (Nodejs) - Testing a AWS S3 Presigned Url returns 403 Forbidden (Nodejs) 如何允许仅通过网站请求使用预签名 url 下载 s3 图像/对象? - how to allow s3 images/object to be downloaded only from by website request using presigned url? S3 为使用 aws-sdk v3 预签名的 PutObject 命令 url 提供 SignatureDoesNotMatch 错误 - S3 gives SignatureDoesNotMatch error for PutObject command pre-signed url using aws-sdk v3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM