From ASP.NET web site I'm calling web service (which requires certificate). When I testing it on localhost (debugging) it works, but on IIS 6 (windows server 2003) it does not works and throws an exception:
The request failed with HTTP status 403: Forbidden.
Here i开发者_如何学运维s the code, how I'm calling web service:
Service service = new Service();
service.ClientCertificates.Add(new X509Certificate("certificate path", "password"));
service.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(ValidationCallBack);
Result res = service.GetResult();
private static bool ValidationCallBack(object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors error)
{
return true;
}
What is the reason of this error and how can I avoid this?
I've tried web service call with winForms and it works fine on server. So I think it is IIS problem...
Thanks!
To resolve this you should look at this link
403 - Forbidden. You can receive this generic 403 status code if the Web site has no default document set, and the site is not set to allow Directory Browsing. For more information about how to resolve this problem, click the following article number to view the article in the Microsoft Knowledge Base:
320051 How to configure the default document in Internet Information Services
403.7 - Client certificate required. You have configured the server to require a certificate for client authentication, but you do not have a valid client certificate installed.
186812 PRB: Error Message: 403.7 Forbidden: Client Certificate Required
You should enable tracing on the server side for a better understanding os this issue. You will see a better exception message or something that will give you a clue.
精彩评论