我对 HSTS 机制感兴趣,想澄清以下时刻:
例如,有站点 https://example.com存在。我用chrome://net-internals/#hsts检查 HSTS 是否已启用。它显示以下信息:
static_sts_domain:
static_upgrade_mode: UNKNOWN
static_sts_include_subdomains:
static_sts_observed:
static_pkp_domain:
static_pkp_include_subdomains:
static_pkp_observed:
static_spki_hashes:
dynamic_sts_domain: example.com
dynamic_upgrade_mode: FORCE_HTTPS
dynamic_sts_include_subdomains: true
dynamic_sts_observed: 1524145911.957196
dynamic_sts_expiry: 1555681911.957194
dynamic_pkp_domain:
dynamic_pkp_include_subdomains:
dynamic_pkp_observed:
dynamic_pkp_expiry:
dynamic_spki_hashes:
所以我期望并认为 HSTS 已在那里启用。但与此同时,没有 Strict-Transport-Security
header 响应。为什么 chrome 会显示此类信息并且该站点启用了 HSTS?
最佳答案
But at the same moment there is no Strict-Transport-Security header in response.
它一定在某个时刻已经存在,因为动态条目已添加到您的 Chrome 实例中。
还要记住,HSTS 可以在任何资源上发送,而不仅仅是主文档。因此,如果您将其发送到 Logo 资源上,那么将为整个域设置它。
您可以使用相同的 chrome://net-internals/#hsts
页面清除它,并查看浏览后它是否会返回?如果是这样,那么某些东西仍在发送它,如果不是,则可能是该网站曾经宣传过 HSTS,但现在不再这样做了。
它的有效期为一年:
(1555681911.957194 - 1524145911.957196) / 365 / 24 / 60 = 1 year
根据我尝试转换这些日期戳的粗略计算,它的最后设置时间似乎是 2018 年 4 月 20 日。
如果网站确实停止使用 HSTS,无论出于何种原因,最好宣传 0 header ,这样至少那些现在通过 HTTPS 访问的访问者将删除该策略:
Strict-Transport-Security: max-age=0; includeSubDomains
任何不通过 HTTPS 访问的人都不会在过期之前清除此设置。
关于security - HSTS理解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50504160/