我创建了自托管的WCF RESTful服务,其基本http身份验证通过https与自签名SSL证书一起运行。一切正常。当用户通过Web浏览器访问服务操作时,他们会弹出询问凭据(登录名/密码)。具有证书身份验证的WCF自托管服务
现在我想做证书认证,而不是基本的,但它不起作用。客户端的浏览器(IE/chrome/firefox)从不提示选择证书,我总是得到一个HTTP 403错误,当我在自定义证书验证器中设置断点时,它永远不会触发。所以我肯定在这里错过了一些东西。我尝试使用Fiddler进行调试,并确认请求中没有验证标头。
这是我的代码来承载服务。
Uri baseAdress = new Uri("https://localhost:8446/");
WebServiceHost host = new WebServiceHost(typeof(RestService));
WebHttpBinding wb = new WebHttpBinding();
wb.Security.Mode = WebHttpSecurityMode.Transport;
wb.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
host.AddServiceEndpoint(typeof(IRestService), wb, baseAdress);
host.Credentials.ClientCertificate.Authentication.CertificateValidationMode =
X509CertificateValidationMode.Custom;
host.Credentials.ClientCertificate.Authentication.CustomCertificateValidator =
new MyX509CertificateValidator()
host.Open();
感谢您的任何提示。
您是否也更新了客户端配置? – evgenyl
所有客户端请求都是在Web浏览器(WebGet)中完成的,而不是代码中的,因此我不知道要更新什么。 –
我想尝试SvcTraceViewer,以及构建您自己的asp页面进行测试。 – evgenyl