aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/http/headers/public-key-pins/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/http/headers/public-key-pins/index.html')
-rw-r--r--files/zh-cn/web/http/headers/public-key-pins/index.html89
1 files changed, 89 insertions, 0 deletions
diff --git a/files/zh-cn/web/http/headers/public-key-pins/index.html b/files/zh-cn/web/http/headers/public-key-pins/index.html
new file mode 100644
index 0000000000..1956085818
--- /dev/null
+++ b/files/zh-cn/web/http/headers/public-key-pins/index.html
@@ -0,0 +1,89 @@
+---
+title: Public-Key-Pins
+slug: Web/HTTP/Headers/Public-Key-Pins
+tags:
+ - 中间人攻击
+ - 公钥
+ - 响应首部
+ - 安全性
+translation_of: Web/HTTP/Headers/Public-Key-Pins
+---
+<div>{{HTTPSidebar}}</div>
+
+<p><code><strong>Public-Key-Pins </strong></code>是一个响应首部,其包含该Web 服务器用来进行加密的 public {{glossary('key')}} (公钥)信息 ,以此来降低使用伪造证书进行 {{Glossary("MITM")}}  (中间人攻击)的风险。如果锚定的加密串与服务器返回的公钥不匹配,那么浏览器将会认定响应不合法,并且不会将结果展示给用户。</p>
+
+<p>更多相关信息请参考 <a href="/en-US/docs/Web/HTTP/Public_Key_Pinning">HTTP Public Key Pinning</a> 这篇文章。</p>
+
+<table class="properties">
+ <tbody>
+ <tr>
+ <th scope="row">Header type</th>
+ <td>{{Glossary("Response header")}}</td>
+ </tr>
+ <tr>
+ <th scope="row">{{Glossary("Forbidden header name")}}</th>
+ <td>no</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">Public-Key-Pins: pin-sha256="&lt;pin-value&gt;";
+ max-age=&lt;expire-time&gt;;
+ includeSubDomains;
+ report-uri="&lt;uri&gt;"</pre>
+
+<h2 id="指令">指令</h2>
+
+<dl>
+ <dt><code>pin-sha256="&lt;pin-value&gt;"</code></dt>
+ <dd>引号里面的是内容是以Base64编码的 {{Glossary("SPKI")}}(公钥) 指纹.你可以为多个不同的公钥都设定对应的pins。 一些浏览器将来可能也支持非SHA-256 的哈希算法。</dd>
+ <dt>max-age=&lt;expire-time&gt;</dt>
+ <dd>指定以秒为单位的时间,在这段时间内,浏览器应该记住, 该站点只能以这些指定的密钥进行访问</dd>
+ <dt><code>includeSubDomains </code>{{optional_inline}}</dt>
+ <dd>如果该选项被指定,该规则也会应用到网站的所有子域名</dd>
+ <dt><code>report-uri="&lt;uri&gt;"</code> {{optional_inline}}</dt>
+ <dd>如果该可选项被指定,一旦pin校验失败,就会发送此相关异常信息给该URL</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<div class="warning">
+<p id="HPKP_has_the_potential_to_lock_out_users_for_a_long_time_if_used_incorrectly!_The_use_of_backup_certificates_andor_pinning_the_CA_certificate_is_recommend.">如果设置不合理,HPKP可能会使得用户长时间不能访问网站。因此建议也同时固定备用证书或者CA证书。</p>
+</div>
+
+<pre>Public-Key-Pins:
+ pin-sha256="cUPcTAZWKaASuYWhhneDttWpY3oBAkE3h2+soZS7sWs=";
+ pin-sha256="M8HztCzM3elUxkcjR2S5P4hhyBNf6lHkmjAHKhpGPWE=";
+ max-age=5184000; includeSubDomains;
+ report-uri="https://www.example.org/hpkp-report"</pre>
+
+<p>在这个例子里面,<strong>pin-sha256="cUPcTAZWKaASuYWhhneDttWpY3oBAkE3h2+soZS7sWs=" </strong>固定了该服务器的公钥. 第二个声明<strong>pin-sha256="M8HztCzM3elUxkcjR2S5P4hhyBNf6lHkmjAHKhpGPWE="</strong> 也固定了服务器的备用公钥. <strong>max-age=5184000</strong> 则是让客户端(浏览器)将该固定扩展信息存储两个月, 这个是IETF RFC建议时间。同时通过<strong>includeSubDomains</strong> 的声明使得该设置对所有子域名都生效;最后, <strong>report-uri="https://www.example.org/hpkp-report"</strong> 则是定义了验证失败时异常信息发送的服务器地址。</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Title</th>
+ </tr>
+ <tr>
+ <td>{{RFC("7469", "Public-Key-Pins", "2.1")}}</td>
+ <td>Public Key Pinning Extension for HTTP</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("http.headers.Public-Key-Pins")}}</p>
+
+<h2 id="相关内容">相关内容</h2>
+
+<ul>
+ <li>{{HTTPHeader("Public-Key-Pins-Report-Only")}}</li>
+</ul>