小编mat*_*mck的帖子

具有证书的编程WCF消息安全性

我使用WSHttpBindings编写了一个自托管的WCF服务,我正在尝试使用我自己生成的证书来实现消息级安全性.不幸的是,我得到了一个隐藏的异常(通过服务跟踪查看器),说明"提供给包的凭据无法识别".

几个笔记:

  1. 这必须在代码中完成,而不是在配置中完成
  2. (服务器/客户端)证书是本地计算机存储中的证书,在调试时我的用户可以访问私钥.
  3. 我GOOGLE了地狱,这一点,并找到了一个很好的资源设置基于WCF消息安全在这里

我不确定我错过了什么.除了创建端点身份之外,大多数这些东西似乎都是直截了当的.无论是使用DnsEndpointIdentities,基于证书的,还是根本没有身份,它都会失败并显示相同的消息.

谁能指出我正确的方向?

服务器端:

var binding = new WSHttpBinding
    {
      Security =
      {
        Mode = SecurityMode.Message,
        Message = 
        {
          ClientCredentialType = MessageCredentialType.Certificate,
          AlgorithmSuite = SecurityAlgorithmSuite.Basic256Sha256Rsa15
        }
      }
    };

_host = new ServiceHost(this)
{
  Credentials =
  {
    ServiceCertificate =
    {
      Certificate = ServiceCert
    },
    ClientCertificate =
    {
      Certificate = ClientCert,
      Authentication =
      {
        TrustedStoreLocation = StoreLocation.LocalMachine,
        RevocationMode = X509RevocationMode.NoCheck,
        CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust
       }
    }
  }
};
var address = new Uri(string.Format(@"http://serviceaddress"));
var ep = _host.AddServiceEndpoint(typeof (IService), …
Run Code Online (Sandbox Code Playgroud)

wcf wshttpbinding x509certificate

8
推荐指数
1
解决办法
8992
查看次数

标签 统计

wcf ×1

wshttpbinding ×1

x509certificate ×1