CloudFront URL Malformed Policy

0

Hey, I have a Cloud Front distribution, with Attached custom policy. As given in below image: Custom Policy screenshot I am creating a signed URL, but it's showing Malformed policy. As given below: Malformed Policy Error

Here is how I am generating the signed URL: Pre Signed URL code

Let me know if I am missing anything.

Base on the answers. And in the first image I have configured cache policy.I have added new code: Signing with custom policy

But still getting the same error. Error that I am getting

2 個答案
1
已接受的答案

Thank you for the details. The cache policy referenced in the first image isn't relevant when it comes to constructing CloudFront signed URLs. Please refer to this document for an example of a custom policy that demonstrates how to control access to a specific file or from an individual IP address, among other things.

As a side note, here are some code examples, though they are not in Python.

AWS
weidi
已回答 1 年前
  • Hey I have update the code based on your input. But still getting the same error. The document says to change some characters, but I am not sure why. DO you have any exampel

  • Thanks for providing additional codes. Looking at https://github.com/boto/botocore/blob/develop/botocore/signers.py#L402-L403 it seems that .encode("utf-8") will not be necessary and worthwhile a try? otherwise we could also try build_policy() mentioned in the library.

  • The same issue persists only when using Wildcard in the Resource URL, if an exact URL is provided, then the issue is resolved. Any idea how to use Wildcards in the Resource URL and not get Malformed Policy response?

0
profile picture
專家
已回答 1 年前
  • I am already able to generate the signed url, but it's not working with custom policy

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南