【问题标题】:WCF - basicHttpBinding configuration (exception: Identity check failed for outgoing message. The expected DNS identity of the remote endpoint ...)WCF - basicHttpBinding 配置(异常:传出消息的身份检查失败。远程端点的预期 DNS 身份......)
【发布时间】:2021-11-20 06:51:51
【问题描述】:

我正在尝试在 VisualStudio 中制作一个肥皂客户端。我所做的第一件事是使用交付的 WSDL 文件生成代理类(使用 VisualStudio 中的添加服务引用选项)。它是使用错误的绑定配置生成的 - 消息安全性应该是: DefaultAsymmetricSignatureAlgorithm - “http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 DefaultCanonicalizationAlgorithm - “http://www .w3.org/2001/10/xml-exc-c14n#"DefaultDigestAlgorithm -"http://www.w3.org/2001/04/xmlenc# sha256",

当它是: DefaultAsymmetricSignatureAlgorithm "http://www.w3.org/2000/09/xmldsig#rsa-sha1" DefaultCanonicalizationAlgorithm "http://www.w3.org /2001/10/xml-exc-c14n#"DefaultDigestAlgorithm"http://www.w3.org/2000/09/xmldsig#sha1".

我通过添加以下内容更改了 App.conf 中的 basicHttpBinding 设置:

<security mode="Message">
            <message algorithmSuite="Basic256Sha256" clientCredentialType="Certificate"/>
</security>

并且绑定设置已正确更改,我还设置了证书:

var cert = new X509Certificate2(AppDomain.CurrentDomain.BaseDirectory + "//cert.p12", "Pass");
client.ChannelFactory.Credentials.ClientCertificate.Certificate = cert;
client.ClientCredentials.ClientCertificate.Certificate = cert;

不幸的是,我遇到了异常: 没有为目标“http://.../service”提供服务证书。在 ClientCredentials 中指定服务证书。

我尝试为 ClientCertificate 和 ServiceCertificate 使用相同的证书(我不知道它是否正常)。

client.ClientCredentials.ServiceCertificate.DefaultCertificate = cert;

但我收到错误:所使用的证书具有无法验证的信任链。更换证书或更改 certificateValidationMode。

将模式更改为无会导致异常找不到安全性

我在 serviceBehaviors/behavior/serviceCredentials/clientCertificate 中添加了 &lt;authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck"/&gt;,但它不起作用。

我还尝试在 endpointBehaviors/behavior/clientCredentials/serviceCertificate 中添加 &lt;authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck"/&gt;

但我遇到了另一个错误: “传出消息的身份检查失败。远程端点的预期 DNS 身份是“nameA”,但远程端点提供了 DNS 声明“nameB”。如果这是一个合法的远程端点,您可以通过明确指定来解决问题DNS 身份 'nameB' 作为 EndpointAddress 创建通道代理时的 Identity 属性。”

而且我不确定我是否走对了。我不知道该怎么办:(

一般来说,使用 SoupUI 发送请求可以正常工作,但我无法在客户端服务中进行正确配置以发送任何请求。

【问题讨论】:

    标签: c# ssl wcf-binding wcf-security x509certificate2


    【解决方案1】:

    当你更改证书时,你需要更新它:

    <identity>
         <certificate encodedValue="xxx" />
    </identity>
    

    它可能仍然指向原来的。

    【讨论】:

      猜你喜欢
      • 2012-10-08
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-13
      相关资源
      最近更新 更多