The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.

未关闭
#19 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
aws, java
领域
cloud

调研方向

从 issue 中显示的 GeneratePreSignedUrl 示例开始,针对报告的 S3 bucket 重现生成的 URL。检查 AWS SDK for Java 对 presigned request 和授权的处理行为,然后验证该示例是否使用所需的授权机制生成一个被 S3 接受的 URL。完成的标准是报告的错误不再发生,或者该示例明确记录受支持的配置。

由索引模型根据 Issue 内容生成。

描述

Below Sample returns subjected error, using latest version of java sdk

package com.amazonaws.samples;

import java.io.IOException;
import java.net.URL;

import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.HttpMethod;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;

public class GeneratePreSignedUrl {
private static String bucketName = "bucketforwso2";
private static String objectKey = "/HTML-CHEAT-SHEET-768x8555.pdf";

public static void main(String[] args) throws IOException {
	@SuppressWarnings("deprecation")
	AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider());

	try {
		System.out.println("Generating pre-signed URL.");
		java.util.Date expiration = new java.util.Date();
		long milliSeconds = expiration.getTime();
		milliSeconds += 1000 * 60 * 60; // Add 1 hour.
		expiration.setTime(milliSeconds);

		GeneratePresignedUrlRequest generatePresignedUrlRequest = 
			    new GeneratePresignedUrlRequest(bucketName, objectKey);
		generatePresignedUrlRequest.setMethod(HttpMethod.GET); 
		generatePresignedUrlRequest.setExpiration(expiration);

		URL url = s3client.generatePresignedUrl(generatePresignedUrlRequest); 

		System.out.println("Pre-Signed URL = " + url.toString());
	} catch (AmazonServiceException exception) {
		System.out.println("Caught an AmazonServiceException, " +
				"which means your request made it " +
				"to Amazon S3, but was rejected with an error response " +
		"for some reason.");
		System.out.println("Error Message: " + exception.getMessage());
		System.out.println("HTTP  Code: "    + exception.getStatusCode());
		System.out.println("AWS Error Code:" + exception.getErrorCode());
		System.out.println("Error Type:    " + exception.getErrorType());
		System.out.println("Request ID:    " + exception.getRequestId());
	} catch (AmazonClientException ace) {
		System.out.println("Caught an AmazonClientException, " +
				"which means the client encountered " +
				"an internal error while trying to communicate" +
				" with S3, " +
		"such as not being able to access the network.");
		System.out.println("Error Message: " + ace.getMessage());
	}
}

}

Generating pre-signed URL.
Pre-Signed URL = https://bucketforwso2.s3.amazonaws.com/%2FHTML-CHEAT-SHEET-768x8555.pdf?AWSAccessKeyId=AKIAJH5K4ZJ6ZQB2F4XB&Expires=1514962084&Signature=rY7RjDwJkck8ZCEGWUr4lSm%2Bkuw%3D

InvalidRequest The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256. 2947D4830B323D3A 4JK5mlUk/a7oOd6WJT5ol5X0prJY+0buLKr9zhnOcoz0mxAk/oc9A/nWHgIC8lggT11xneCtRLU=
主要语言
Java
星标
241
派生
345
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aws-samples/aws-java-sample 的其他 Issue

查看 aws-samples/aws-java-sample 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。