99770 2017-8-2 08:48
如何取消清除Chrome跟Firefox 的 HSTS 設定
HSTS簡介:HSTS全名是HTTP Strict Transport Security 中文名「強制安全傳輸技術」,原理是在第一次訪問https網站時,網站的回覆表頭帶有「Strict-Transport-Security」,該表頭會讓瀏覽器記得,該網站(正確說法是域名)有提供HTTPS安全連線,並於下次連線中強制使用HTTPS,注意是強制喔,不論是點進不帶有https的連結(例如:這個),或是你故意在網址列打入網址時使用http://為開頭,瀏覽器都會先強制轉換成https再送出請求.<br><br>那有沒有可能那一天反悔不使用了呢?該如何清除設定呢?<br><br>在Chrome 下清除 HSTS 設定:<br><br>Navigate to <font color="#ff0000">chrome://net-internals/#hsts</font><br><br>在Delete domain區域中的文字格輸入你要清除HSTS設定的域名(1),然後按「Delete」(2)<br><a href="https://blog.bennyling.cc/wp-content/uploads/2016/06/step1.png" target="_blank"><img src="https://blog.bennyling.cc/wp-content/uploads/2016/06/step1.png" alt="" width="499" border="0" height="95"></a><br>按完之後,啥事都不會發生,所以要確認下有沒有成功刪除HSTS<br><br>在下方Query domain的區域中的文字格輸入你剛剛刪除的域名,然後按「Query」<br><a href="https://blog.bennyling.cc/wp-content/uploads/2016/06/query.png" target="_blank"><img src="https://blog.bennyling.cc/wp-content/uploads/2016/06/query.png" alt="" width="494" border="0" height="90"></a><br><br><font color="#339966">成功</font>刪除的話應該會像下圖情況,下方出現Not found的提示<br><a href="https://blog.bennyling.cc/wp-content/uploads/2016/06/ok.png" target="_blank"><img src="https://blog.bennyling.cc/wp-content/uploads/2016/06/ok.png" alt="" width="302" border="0" height="116"></a><br><br><font color="#ff0000">失敗</font>的話如下圖,瀏覽器會回報關於該域名HSTS的資訊<br><a href="https://blog.bennyling.cc/wp-content/uploads/2016/06/found.png" target="_blank"><img src="https://blog.bennyling.cc/wp-content/uploads/2016/06/found.png" alt="" width="306" border="0" height="374"></a><br><br><br>在Firefox 下清除 HSTS 設定:<br><br>We will cover two different methods for deleting HSTS settings in Firefox. The first method should work in most cases – but we also included a manual option if needed.<br><br> Close all open tabs in Firefox.<br> Open the full History window with the keyboard shortcut Ctrl + Shift + H (Cmd + Shift + H on Mac). You must use this window or the sidebar for the below options to be available.<br> Find the site you want to delete the HSTS settings for – you can search for the site at the upper right if needed.<br> Right-click the site from the list of items and click Forget About This Site.This should clear the HSTS settings (and other cache data) for that domain.<br> Restart Firefox and visit the site. You should now be able to visit the site over HTTP/broken HTTPS.If these instructions did not work, you can try the following manual method:<br><br><p><strong>Manual Method for Firefox</strong></p><p><strong><br></strong></p><p><strong>
</strong>If the above steps do not work, you can try the following method.</p>
<p>Start by locating your Firefox profile folder through your operating
system’s file explorer. You can find this folder through Firefox by
navigating to <strong>about:support </strong></p>
<p>Halfway down the page, in the Application Basics section, you will see <strong>Profile Folder</strong>. Click <strong>Open Folder.</strong></p><p><strong><br></strong></p>
<p>Now <strong>close Firefox</strong> so that the browser does not overwrite any settings we are about to change.</p>
<p>In your Profile folder find and open the file <strong>SiteSecurityServiceState.txt</strong>.
This file contains cached HSTS and HPKP (Key Pinning, a separate HTTPS
mechanism) settings for domains you have visited. It may be very
disorganized.</p><p><br></p>
<p>Search for the domain you want to clear the HSTS settings for and
delete it from the file. Each entry beings with the domain name. Delete
the entirety of the entry from the beginning of the desired domain name
to the next listed domain. As an alternative, you can rename the
existing file from a .txt to a .bak (in order to save the existing file,
just in case) and allow Firefox to create an entirely new file on next
start up.</p><p><br></p>
<p>Here is an example of a simple HSTS listing:</p>
<p>www.thesslstore.com:HSTS 0 17312 1527362896190,1,0</p>
<p>As mentioned, the formatting for this file can be messy. Below is a
sample from my profile. Each domain’s settings are shown in a unique
color to make separation clear. In this case, part of the settings for
the previous domain appear the beginning in red:</p><p><br></p>
<p><span style="color: #ff0000;">1527363079029,1,0</span><span style="color: #0000ff;">www.thesslstore.com:HSTS 0 17312</span><br>
<span style="color: #0000ff;">1527362896190,1,0</span><span style="color: #339966;">scotthelme.co.uk:HPKP
0 17312
1498419087277,1,1,9dNiZZueNZmyaf3pTkXxDgOzLkjKvI+Nza0ACF5IDwg=X3pGTSOuJeEVw989IJ/cEtXUEmy52zs1TZQrU06KUKg=V+J+7lHvE6X0pqGKVqLtxuvk+0f+xowyr3obtq8tbSw=9lBW+k9EF6yyG9413/fPiHhQy5Ok4UI5sBpBTuOaa/U=ipMu2Xu72A086/35thucbjLfrPaSjuw4HIjSWsxqkb8=+5JdLySIa9rS6xJM+2KHN9CatGKln78GjnDpf4WmI3g=MWfCxyqG2b5RBmYFQuLllhQvYZ3mjZghXTRn9BL9q10=</span><br>
<span style="color: #0000ff;">api.github.com:HSTS 0 17312 1527362865303,1,1</span></p><p><span style="color: #0000ff;"><br></span></p><p><span style="color: #0000ff;"><br></span></p><p><span style="color: #0000ff;">參考資料: <br></span></p><p><span style="color: #0000ff;">https://www.thesslstore.com/blog/clear-hsts-settings-chrome-firefox/</span></p><p><span style="color: #0000ff;">https://blog.bennyling.cc/362/clear-google-chrome-hsts-setting/<br></span></p>