Presigned PUT request doesn't validate the Content-MD5?

0

I am using the Java v2 SDK to create a presigned URL. While creating the PutObjectRequest with the builder I also set the contentMD5 with the base64 encoded MD5 hash of the file that will be eventually uploaded with this obtained URL. According to the docs here, I can only use Content-MD5 for object integrity verification.

So, once I obtain the URL, I should be able to only upload the file whose MD5 hash matches the value that was supplied during the signed URL creation. If I choose to upload a different file, it should fail? But what I see is that it allows to upload any file, so is that not how the MD5 integrity check works?

To test further, I added the Content-MD5 header again in a Postman PUT request when uploading to AWS using the obtained presigned URL and this time it verifies it. Is it the expectation that the Content-MD5 hash has to be available during the signed URL creation and also in the PUT request?

Amit
질문됨 2달 전261회 조회
1개 답변
0

Hi, When you create a presigned URL for uploading an object to S3 and include the Content-MD5 header in the PutObjectRequest, it means that AWS will expect the uploaded object to have the same MD5 hash as the one provided in the Content-MD5 header. If the uploaded object's MD5 hash doesn't match the expected value, AWS will reject the request.

However, it's essential to ensure that the Content-MD5 header is included both during the presigned URL creation and in the actual PUT request made to S3. If the Content-MD5 header is missing in the PUT request, S3 won't perform the integrity check, and the upload will succeed regardless of the object's MD5 hash.

Therefore, to enforce the integrity check:

  1. Include the Content-MD5 header when creating the presigned URL.
  2. Include the Content-MD5 header in the PUT request made using the presigned URL.

By doing so, AWS will verify that the uploaded object's MD5 hash matches the expected value, providing an additional layer of integrity verification for your uploads.

profile picture
답변함 2달 전
profile picture
전문가
검토됨 한 달 전
  • Hi Hari Priya, Thank you for the response. So this means that if I were to actually provide the original Content-MD5 header in the PUT request, but try to upload a different image in the body/payload then S3 will not allow that and it would fail?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠