![](/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.