【问题标题】:WCF client with Client Certificate and Basic Authentication具有客户端证书和基本身份验证的 WCF 客户端
【发布时间】:2012-01-03 02:18:49
【问题描述】:

我需要访问我们其中一位合作伙伴的网络服务。 他们的服务受到客户端证书和基本身份验证的保护。 我正在使用带有 BasicHttpBinding 的 WCF。

我可以使用传输级安全性连接证书。 我知道证书正在工作,因为我不再收到 403 错误,但我收到 401 是因为我无法将凭据与传输一起传递。 据我所知,我只能有一种传输安全方案。

我怎样才能做到这一点?

<security mode="Transport">
     <transport type="Certificate" />
     <transport type="Basic" />
</security>

谢谢

【问题讨论】:

  • 请显示尝试访问 WCF 服务的客户端代码...
  • 能否说明一下服务配置。他们在使用 WCF 吗?如果是这样,您能否显示 web.config 或服务配置代码?
  • 配置是否在传输级别使用带有基本身份验证的 SSL(不是双向 SSL),以及使用客户端证书的消息级别加密?

标签: c# wcf-security basic-authentication basichttpbinding client-certificates


【解决方案1】:

您是否尝试在消息级别传递凭据。 您的配置应如下所示:

<security mode="Transport">
        <transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
</security>

然后在代码中

 WebServiceProxy objClient = new WebServiceProxy ();
  objclient.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "clientCert");
 objClient.ClientCredentials.UserName.UserName = "username";
 objClient.ClientCredentials.UserName.Password = "Password";

【讨论】:

  • 问题表明他使用的是 Basic Authenticatin - 因此是传输级别,而不是消息级别。
猜你喜欢
  • 1970-01-01
  • 2011-04-09
  • 2013-10-07
  • 2018-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多