問題:
我們給IIS上的網(wǎng)站設置的類型為:https,并且設置了SSL,我們在訪問程序時可能會報錯:System.Security.Authentication.AuthenticationException: 根據(jù)驗證過程,遠程證書無效 。
解決:
System.Security.Authentication.AuthenticationException: 根據(jù)驗證過程,遠程證書無效 。”這個異常,是因為遠程url使用的域名沒有購買證書,所以需要在報錯的代碼前加一句話:ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate;
RemoteCertificateValidate事件代碼如下:文章來源:http://www.zghlxwxcb.cn/news/detail-832711.html
//為了通過遠程證書驗證,總是返回true文章來源地址http://www.zghlxwxcb.cn/news/detail-832711.html
private static bool RemoteCertificateValidate(object sender, X509Certificate cert,X509Chain chain, SslPolicyErrors error)
{
return true;
}
到了這里,關于解決IIS 驗證遠程SSL證書無效的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!