略過憑證不符

參考資料:(http://blog.darkthread.net/post-2010-05-06-webclient-ssl-dismatch.aspx)

當獲得錯誤訊息為

The underlying connection was closed: Could not establish trust relationship for SSL/TLS secure channel (中文版為: 基礎連接已關閉: 無法為 SSL/TLS 安全通道建立信任關係。)

此時可利用下列程式碼,去略過

WebClient wc = new WebClient();
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

Last updated