【问题标题】:How can I read the Clientcertificate within a WCF service?如何在 WCF 服务中读取 Clientcertificate?
【发布时间】:2011-07-18 08:35:51
【问题描述】:

我确实在要求客户端使用 x509 证书进行身份验证的服务器上托管 WCF 服务。我需要在服务中读取此证书,因为其中包含的数据是业务逻辑的一部分。

我用于 WCF 服务的绑定是 webHttpBinding,安全设置为“Transport”和 clientCredentialType="certificate"。

在 ASP.net 中,我可以使用 HttpContext.Current,但在 WCF 中不可用。我该怎么做才能从用户那里获得证书?

亲切的问候, 阿洛伊斯

【问题讨论】:

    标签: c# wcf client-certificates


    【解决方案1】:

    http://blogs.msdn.com/b/wenlong/archive/2006/01/23/516041.aspx 上的文章为我提供了解决此问题的方法。 WCF 允许在“ASP.net 兼容模式”下运行,这会带回完整的 HttpContext 对象。

    【讨论】:

      【解决方案2】:

      我在我的 WCF 服务中使用它,禁用了 ASP.net 兼容性:

      var x509ClaimSet = OperationContext.Current.ServiceSecurityContext.AuthorizationContext.ClaimSets.FirstOrDefault() as X509CertificateClaimSet;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-04-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多