惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
P
Privacy & Cybersecurity Law Blog
Cisco Talos Blog
Cisco Talos Blog
Blog — PlanetScale
Blog — PlanetScale
博客园 - 叶小钗
爱范儿
爱范儿
C
CERT Recently Published Vulnerability Notes
Hugging Face - Blog
Hugging Face - Blog
P
Proofpoint News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Know Your Adversary
Know Your Adversary
Latest news
Latest news
T
Tor Project blog
NISL@THU
NISL@THU
The Hacker News
The Hacker News
IT之家
IT之家
Last Week in AI
Last Week in AI
T
Tenable Blog
C
Cybersecurity and Infrastructure Security Agency CISA
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Visual Studio Blog
Apple Machine Learning Research
Apple Machine Learning Research
T
Threat Research - Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
博客园 - 三生石上(FineUI控件)
Spread Privacy
Spread Privacy
S
Secure Thoughts
博客园 - 司徒正美
A
About on SuperTechFans
Attack and Defense Labs
Attack and Defense Labs
Microsoft Security Blog
Microsoft Security Blog
N
News and Events Feed by Topic
O
OpenAI News
V
V2EX
aimingoo的专栏
aimingoo的专栏
L
LangChain Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Security Affairs
MyScale Blog
MyScale Blog
S
Schneier on Security
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - Bo Schwarzstein

发布关于PostGIS对于USD格式的拓展 紫微斗数之自化禄真的是损耗嘛? 紫微斗数个人经验之三合或者四化看哪个 A Practical Methodology, HSM, Handler,Service,Model, for Golang Backend Development 问ChatGPT玄学问题,看来命理师还是不会被取代的 Compile Sqlite3 Executable, Static Library, and Shared Library on Linux Benchmark JuiceFS at AWS 2 Benchmark JuiceFS on AWS 1 Work with AWS VPC, Lambda and Internet Far & Unifield Field Augmented Reality 紫微斗数是否对外国人有用 2022壬寅年天干四化 《中有成就秘笈》之中央密严刹土 IPFS与般若文海 Moira果老星宗七政四余排盘软件下载 Play Old Diablo 2 on macOS Catalina Use Go Micro Web with HTTP Handler 视频平台设计思路大灌顶 Unity Input System教程
Create CloudFront Signed URL in 1 Minute
Bo Schwarzstein · 2022-04-12 · via 博客园 - Bo Schwarzstein

Assume we have

  • AWS Bucket: test-bucket
  • AWS Object: /test-file.jpg
  • AWS Cloudfront: https://test-cdn.cloudfront.net/

Assume the Cloudfront has Original associated with the bucket, let's create signed URL for the file for restricted access.

Step 1 Generate RSA Key Pair for CloudFront

Create private key firstly.

openssl genrsa -out private_key.pem 2048

Extract public key from private key.

openssl rsa -pubout -in private_key.pem -out public_key.pem

Create key group at CloudFront according here, assume the public key ID is test-public-id.

Step 2 Construct Policy for S3 Object

Do not mess up with the Policy CloudFront at panel, the Policy here means the content of signed URL.

Create a JSON text file as below and save it to /tmp/test-policy.txt

{
    "Statement":[
        {
            "Resource":"https://test-cdn.cloudfront.net/test-file.jpg",
            "Condition":{
                "DateLessThan":{
                    "AWS:EpochTime":1649815417
                }
            }
        }
    ]
}

Step 3 Create Signature

Use one line command to generate signed signature for the URL.

cat /tmp/test-policy.log | tr -d "\n" | tr -d " \t\n\r" | openssl sha1 -sign private_key.pem | openssl base64 -A | tr -- '+=/' '-_~'

It would print text test-signature at console which is the signature part of final URL.

Step 4 Construct URL

The URL would be

https://test-cdn.cloudfront.net/test-file.jpg?Expires=1649815417&Signature={test-signature}&Key-Pair-Id={test-public-id}

Done.

posted on 2022-04-12 11:07  Bo Schwarzstein  阅读(416)  评论()    收藏  举报