售前咨询
技术支持
渠道合作

如何在HSTS预加载列表中添加Expect-C和Expect-Staple条目

提示:本文需要读者对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”: “scotthelme.co.uk”, “include_subdomains”: true, “mode”: “force-https” },

无论是构建现有条目还是创建新条目,都需要启用相关功能添加适当的字段。 以下是需要分别为Expect-CT和Expect-Staple添加的值。

“expect_ct”: true, “expect_ct_report_uri”: “https://scotthelme.report-uri.com/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”: “scotthelme.co.uk”, “include_subdomains”: true, “mode”: “force-https”, “expect_ct”: true, “expect_ct_report_uri”: “https://scotthelme.report-uri.com/r/d/ct/reportOnly”, “include_subdomains_for_expect_ct”: true, “expect_staple”: true, “expect_staple_report_uri”: “https://scotthelme.report-uri.com/r/d/staple/reportOnly”, “include_subdomains_for_expect_staple”: true},

这个新条目需要放在手动输入部分。可以通过搜索//START OF MANUAL ENTRIES来查找整个部分的初始内容,也可以搜//END OF MANUAL ENTRIES找到末尾信息。将新条目放在最后。一旦保存了更改,如果没有全局设置或者想要再度更改,则需要在Git中操作。

git config user.name “Scott Helme”

git config user.email “scotthelme@hotmail.com”

git config core.autocrlf false

git config core.filemode false

git config branch.autosetuprebase always

git config gerrit.host true

email地址必须使用谷歌账号且在验证过后才能生效。转到此链接并选择合适的Google帐户(如果您有多个帐户),就会提示您运行配置git所需的命令,列出的命令为:

touch .gitcookies

chmod 0600 .gitcookies

git config http.cookiefile .gitcookies

tr , \\t <<\__END__ >>.gitcookies

*stuff here*

__END__

这里修改了删除全局设置的命令,并将.cookies文件放在本地目录中而非用户主目录。

git commit -a

最后一步是下载depot_tools:

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

export PATH=`pwd`/depot_tools:”$PATH”

现在可以上传更改了!

git cl upload -r lgarron@chromium.org

该命令将上传您的更改,并将其标记为当前HSTS预压列表维护人Lucas Garron审核。 该命令还会提供一个地址,您可以查看提交的更改。 需要跳到此链接,并登陆您的Google帐户,然后点击“开始审核”,否则您的更改无法进行。 随着更改提交并等待审核,现在需要证明此请求来自域的真正所有者/管理员。 只需要提交NS TXT记录来批准请求。 格式在HSTS预加载列表Wiki上的报告URI客户部分中概述,如下所示。

example.com. … “Please preload example.com for [Expect-CT/Expect-Staple/Expect-CT and Expect-Staple] using [subdomain].report-uri.com”

然后收到长这样的记录:

scotthelme.co.uk. 299 IN TXT “Please preload scotthelme.co.uk for Expect-CT and Expect-Staple using scotthelme.report-uri.com”

为您的域名以及想要启用的功能更新这个记录。然后待审核员(Lucas)过目后,您的域名就可以出现在下一版Chrome中的预加载列表中啦!

文章翻译于scotthelme.co.uk

上一篇:

下一篇:

相关文章