![](/img/trans.png)
[英]The HTTP request is unauthorized with client authentication scheme 'Anonymous'?
[英]Sending client certificate via WCF to causes an error: "The HTTP request was forbidden with client authentication scheme 'Anonymous'"
我有一个 IIS ASP.NET 服务,需要通过 WCF https 调用另一个 IIS 服务,其中另一个服务需要客户端证书。
按照本指南,我添加了以下代码(在源端):
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
binding.Security.Mode = SecurityMode.Transport;
m_wcfProxy = new IISSecurityServices.SecurityServiceClient();
m_wcfProxy.Endpoint.Binding = binding;
m_wcfProxy.Endpoint.Address = new EndpointAddress(m_wcfProxyEndpointAddress);
m_wcfProxy.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2("D:\\0\\SslClientCert.cer"); ;
上面唯一的区别是我从文件加载证书(与目标服务使用的证书相同)。
现在,当我拨打电话时,出现以下错误:
客户端身份验证方案“匿名”禁止 HTTP 请求
我看不到我在这里错过了什么。
有没有人知道为什么这对我不起作用?
提前致谢
注意那篇文章的这一段。
在这种情况下,该服务托管在配置了安全套接字层 (SSL) 的 Internet 信息服务 (IIS) 下。 该服务配置了 SSL (X.509) 证书,以允许客户端验证服务器的身份。 客户端还配置了 X.509 证书,允许服务验证客户端的身份。 服务器的证书必须被客户端信任,客户端的证书必须被服务器信任。
在服务器端,承载具有传输安全性的 WCF 需要在 IIS 站点绑定模块中进行 Https 绑定,即将证书绑定到端口,然后通过该端口公开服务。 另外请注意,如果你使用的是自签名证书,我们应该建立服务器端和客户端之间的信任关系,即在本地的Trusted Root Certification Authorities
安装彼此的证书。
如果问题仍然存在,请随时告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.