就像這個人一樣,我一直在為瀏覽器快取SSL會話而苦惱。簡而言之,如果選擇了客戶證書,就沒有辦法以編程方式清除狀態,除非在 IE 中使用 document.execCommand("ClearAuthenticationCache").
其中一個答案提到,向 "同一主機名上需要客戶證書但拒絕所有證書的URL "發出請求時,將迫使瀏覽器清除SSL會話。我怎樣才能在IIS中設定這樣一個端點?因為我想我需要的不僅僅是一個簡單的回傳http狀態403或類似的端點。
uj5u.com熱心網友回復:
SSL協商發生在發送端點請求之前,所以沒有辦法根據端點來 "拒絕證書"(你也許可以強制重新協商,但我不確定IIS是否支持)。
但是你也許可以設定相同的主機名和不同的port,并在那里禁用客戶證書。由于主機名匹配(相同......),我希望瀏覽器會嘗試它們,但會失敗。
uj5u.com熱心網友回復:
簡短的回答。
delete sslcert [ipport=]IP Address:portref
如果你想用代碼撰寫腳本/自動化,你可以用C#在下面的兩個步驟中完成,你需要調整代碼以適應你的需要
1. 獲取你的證書
使用(var store = new X509Store(StoreName.My, StoreLocation.LocalMachine)
{
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly)。
// 獲取/顯示所有證書的串列
foreach (var x in store.Certificate)
{
// *** TODO
// 將其添加到一個下拉串列中
// SomeDropDownListControl_IISCert.Items.Add(new SomeDropDownListControl_IISCert(x.FriendlyName, x.SerialNumber))。
/或洗掉它,見下文
}
}
2.
2.建立命令并傳遞證書,用Shell命令洗掉它
。
StringBuilder str = new StringBuilder();
ProcessStartInfo psi = new ProcessStartInfo() {CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true};
psi.FileName = "netsh";
psi.Arguments = $"http show sslcert ipport=0.0.0.0:{port}"。
Process procShow = Process.Start(psi);
while (procShow != null && !procShow.StandardOutput.EndOfStream)
{
str.Append(procShow.StandardOutput.ReadLine())。
}
Log.Warn(str.ToString)。
// 洗掉IPV4。
psi.Arguments = $"http delete sslcert ipport=0.0.0.0:{port}" 。
Process procDel = Process.Start(psi);
//exitCode = procDel.ExitCode。
StringBuilder str = new StringBuilder();
ProcessStartInfo psi = new ProcessStartInfo() {CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true};
psi.FileName = "netsh";
psi.Arguments = $"http show sslcert ipport=0.0.0.0:{port}"。
Process procShow = Process.Start(psi);
while (procShow != null && !procShow.StandardOutput.EndOfStream)
{
str.Append(procShow.StandardOutput.ReadLine())。
}
Log.Warn(str.ToString)。
// 洗掉IPV4。
psi.Arguments = $"http delete sslcert ipport=0.0.0.0:{port}" 。
Process procDel = Process.Start(psi);
//exitCode = procDel.ExitCode。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/317208.html
標籤:
