提示:本文需要读者对HSTS预加载的相关概念有基本理解。
添加Expect-CT和/或Expect-Staple
想要更改预加载列表,根据需要添加或更新条目,你必须对Chromium源提交一个更改。
首先,需要检查Chromium源,避免拉下整个代码库,可以使用此脚本来拉下所需的部分。 可通过创建一个新目录解决问题,你可以随时随地进行此操作。mkdir ~/chromium
cd ~/chromium
wget https://gist.githubusercontent.com/lgarron/73cf22ed381ef9786739ee5abd816c59/raw/241c176168d9cbec8c2b5e9e90a81da77d518f76/checkout-chromium-preload-list.sh
chmod +x checkout-chromium-preload-list.sh
现在脚本已经准备就绪,可以检出Chromium源并更改到文件夹中。
./checkout-chromium-preload-list.sh
cd chromium-hsts
需要更改的文件现在可以编辑,可以使用您熟悉的任何编辑器。
nano net/http/transport_security_state_static.json
该文件非常大,按照预加载列表中的当前列表(如果有的话),进行的更改内容。如果已有条目并且通过HSTS预装站点提交,则需要找到该条目并将其剪切粘贴到手动条目部分。 如果您还没有条目,需要新建到手动条目部分。
{ “name”: “trustauth.cn”, “include_subdomains”: true, “mode”: “force-https” },
无论是构建现有条目还是创建新条目,都需要启用相关功能添加适当的字段。 以下是需要分别为Expect-CT和Expect-Staple添加的值。
“expect_ct”: true, “expect_ct_report_uri”: “https://scotthelme.trustauth.cn/r/d/ct/reportOnly”, “include_subdomains_for_expect_ct”: true
“expect_staple”: true, “expect_staple_report_uri”: “https://scotthelme.report-uri.io/r/d/staple/reportOnly”, “include_subdomains_for_expect_staple”: true
这是现有的HSTS预加载入口,且同时包含Expect-CT和Expect-Staple最后的结果如下:
{ “name”: “trustauth.cn”, “include_subdomains”: true, “mode”: “force-https”, “expect_ct”: true, “expect_ct_report_uri”: “https://scotthelme.trustauth.cn/r/d/ct/reportOnly”, “include_subdomains_for_expect_ct”: true, “expect_staple”: true, “expect_staple_report_uri”: “https://scotthelme.trustauth.cn/r/d/staple/reportOnly”, “include_subdomains_for_expect_staple”: true},
这个新条目需要放在手动输入部分。可以通过搜索//START OF MANUAL ENTRIES来查找整个部分的初始内容,也可以搜//END OF ... 更多