繁体   English   中英

WCF 客户端到 WSE 3.0 服务异常:CWWSS7310E:XML 加密信息 [.....]

[英]WCF Client to WSE 3.0 service Exception: CWWSS7310E: XML encryption information[.....]

我以前从未使用过肥皂服务,所以我可能做错了什么。 我通过带有“Svcutil”的 wsdl 为该服务生成了一个服务客户端引用。

我遵循了本指南https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-a-wcf-client-to-interoperate-with-wse3-0 -services并设置自定义绑定。 之后,我从引用中获取客户端并提供一个使用 WseSecurityAssertion.MutualCertificate10 和服务端点地址的新绑定。

然后我添加一个证书并将这些凭据添加到服务客户端:

clientProxy.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(string.Concat(xxx, yyy), GetCertificatePassword(xxx), PersistKeySet);
            clientProxy.ClientCredentials.ServiceCertificate.DefaultCertificate = new X509Certificate2(xxx, "", PersistKeySet);
            clientProxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = ChainTrust;
            clientProxy.ClientCredentials.ServiceCertificate.Authentication.RevocationMode = NoCheck;

这是以前工作过的代码(但在使用 wcf 和“Svcutil”之前),我主要是复制它,但稍微重构了它。

当我调用 Web 服务时,出现此错误:

System.ServiceModel.FaultException: 'CWWSS5511E: An exception occurred during the decryption of a message. The exception is CWWSS7310E: XML encryption information exists in the security header, however an inbound XML encryption configuration is not present.'

我知道我加密了一些我不应该加密的东西,当我将使用旧代码发送的请求与我现在发送的请求进行比较时,我可以看到这已添加到 securityheader 中:

<e:EncryptedKey Id="_0" xmlns:e="http://www.w3.org/2001/04/xmlenc#"><e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" xmlns="http://www.w3.org/2000/09/xmldsig#"/></e:EncryptionMethod><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">

还有一些关于钥匙的信息。

我想知道代码以前没有做错的是我做错了什么。 我找不到任何配置文件,所以我认为这不是我遗漏的一些配置。 可以在哪里设置此加密? 它是在绑定内部还是在我设置 clientCredentials 的地方?

所以经过大量的阅读和比较,我最终发现我没有在新一代服务参考文件中将ProtectionLevel设置为System.Net.Security.ProtectionLevel.Sign。 这可能是在旧版本中硬编码的,而不是使用配置文件来设置 ProtectionLevel。 这就是导致服务端的服务不明白如何正确解密的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM