安全 headers Strict-Transport-Security 可用于 http?

security headers Strict-Transport-Security available for http?

我正在阅读 the list of useful header from OWASP,但我无法理解前两个是否需要 HTTPS 证书?

  • Public Key Pinning Extension for HTTP : The Public Key Pinning Extension for HTTP (HPKP) is a security header that tells a web client to associate a specific cryptographic public key with a certain web server to prevent MITM attacks with forged certificates.

  • Strict-Transport-Security : HTTP Strict-Transport-Security (HSTS) enforces secure (HTTP over SSL/TLS) connections to the server. This reduces impact of bugs in web applications leaking session data through cookies and external links and defends against Man-in-the-middle attacks. HSTS also disables the ability for user's to ignore SSL negotiation warnings.

是的,他们都需要证书:

  • 第一个固定证书列表。其中之一必须在当前证书链中。
  • 如果当前 https 连接有效,第二个强制使用 https。

所以根据定义,第一个需要 https 和证书,而 HSTS 的规范禁止使用 http 连接发送 header。

HTTP Public Key Pinning(HPKP) 是一种信任首次使用技术。当用户第一次请求 Web 服务器时,服务器会告知通过特殊的 HTTP header 将自己或中间 CA 的 public 密钥固定到浏览器。之后,浏览器会在给定的时间段内存储此密钥。根据用户对该 Web 服务器的后续请求,浏览器希望将固定密钥包含在 Web 服务器证书链中的一个证书中。如果不是,则通过发出警告来阻止用户。更多信息可以参考Implementing and Testing HTTP Public Key Pinning (HPKP)