?
本文檔使用 php中文網手冊 發(fā)布
HTTP Public-Key-Pins
響應頭將特定的加密公鑰與特定的 Web
服務器相關聯(lián),以降低偽造證書對 MITM 攻擊的風險。如果一個或多個密鑰被固定并且服務器不使用任何密鑰,則瀏覽器將不會接受該合法的響應,并且不會顯示它。
有關更多信息,請參閱 HTTP 公用密鑰固定文章。
Header type | Response header |
---|---|
Forbidden header name | no |
Public-Key-Pins: pin-sha256="<pin-value>"; max-age=<expire-time>; includeSubDomains; report-uri="<uri>"
pin-sha256="<pin-value>"
引用的字符串是 Base64 編碼的主題公鑰信息(SPKI)指紋??梢詾椴煌墓€指定多個引腳。一些瀏覽器可能會在將來允許其他散列算法而不是 SHA-256。max-age = <expire-time> 瀏覽器應該記住,該站點只能使用其中一個定義的鍵來訪問的時間,以秒為單位。includeSubDomains
可選如果指定了此可選參數(shù),則此規(guī)則也適用于所有網站的子域。report-uri="<uri>"
可選如果指定了此可選參數(shù),則將引腳驗證失敗報告給給定的 URL。
如果使用不當,HPKP 可能會長時間鎖定用戶!建議使用備份證書和/或固定 CA 證書。
Public-Key-Pins: pin-sha256="cUPcTAZWKaASuYWhhneDttWpY3oBAkE3h2+soZS7sWs="; pin-sha256="M8HztCzM3elUxkcjR2S5P4hhyBNf6lHkmjAHKhpGPWE="; max-age=5184000; includeSubDomains; report-uri="https://www.example.org/hpkp-report"
在本例中,pin-sha256 =“cUPcTAZWKaASuYWhhneDttWpY3oBAkE3h2 + soZS7sWs =”固定生產中使用的服務器公鑰。第二個引腳聲明pin-sha256 =“M8HztCzM3elUxkcjR2S5P4hhyBNf6lHkmjAHKhpGPWE =”也引腳備份密鑰。max-age = 5184000告訴客戶將這些信息存儲兩個月,根據IETF RFC這是一個合理的時間限制。此關鍵固定也適用于所有子域,這由includeSubDomains聲明告知。最后,report-uri =“ https://www.example.org/hpkp-report ”說明報告引腳驗證失敗的位置。
Specification | Title |
---|---|
RFC 7469, section 2.1: Public-Key-Pins | Public Key Pinning Extension for HTTP |
Feature | Chrome | Firefox | Edge | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic Support | (Yes) | 35.0 | (No)1 | ? | (Yes) | ? |
report-uri | 46 | (No)2 | ? | ? | 33 | ? |
Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | ? | 35.0 | ? | (Yes) | ? |
report-uri | (Yes) | (Yes) | ? | (No) | ? | 33 | ? |
Under consideration 未來發(fā)布。
參見 Bugzilla 錯誤 1091176。