Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在ASP.NET MVC中实现ServerCertificateValidationCallback?_C#_Asp.net Mvc_Ssl_Ssl Certificate_Client Certificates - Fatal编程技术网

C# 如何在ASP.NET MVC中实现ServerCertificateValidationCallback?

C# 如何在ASP.NET MVC中实现ServerCertificateValidationCallback?,c#,asp.net-mvc,ssl,ssl-certificate,client-certificates,C#,Asp.net Mvc,Ssl,Ssl Certificate,Client Certificates,我想通过X509证书添加客户端身份验证,因此我将我的服务器IIS设置为SSL和所需的客户端证书。 (正如这里所说:) 但是,一旦客户机选择了证书,服务器将始终回答HTTP 403 因此,为了自定义我在global.asax中添加的客户端证书的验证: protected void Application_Start() { ....... ServicePointManager.ServerCertificateValidationCallbac

我想通过X509证书添加客户端身份验证,因此我将我的服务器IIS设置为SSL和所需的客户端证书。 (正如这里所说:)

但是,一旦客户机选择了证书,服务器将始终回答HTTP 403

因此,为了自定义我在global.asax中添加的客户端证书的验证:

     protected void Application_Start()
     {
        .......
        ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateServerCertificate);

        private static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {            
         //... checking
         return true;
        }
     }
但显然我的函数从未被调用,服务器响应仍然是403权限被拒绝(证书被判定为不安全)

你有什么建议吗