& # 39;行动# 39;& # 39;http://www.w3.org/2005/08/addressing& #

本文关键字:2005 addressing org 行动 http www w3 | 更新日期: 2023-09-27 17:50:09

我正在从WCF客户端访问一个我无法控制的基于java的外部web服务,使用双重证书进行加密和签名以及自定义绑定。我从服务器得到一个成功的响应,但WCF抛出一个MessageSecurityException: 'Action', 'http://www.w3.org/2005/08/addressing'所需的消息部分未签名。

我的自定义绑定:

private CustomBinding GetCustomBinding()
{
    CustomBinding binding = new CustomBinding();
    binding.OpenTimeout = new TimeSpan(0, 0, 20);
    binding.CloseTimeout = new TimeSpan(0, 0, 20);
    binding.SendTimeout = new TimeSpan(0, 5, 0);
    binding.ReceiveTimeout = new TimeSpan(0, 5, 0);
    var userNameToken = new UserNameSecurityTokenParameters();
    userNameToken.InclusionMode = SecurityTokenInclusionMode.AlwaysToRecipient;
    var securityElement = new AsymmetricSecurityBindingElement();
    securityElement.EnableUnsecuredResponse = true;
    securityElement.IncludeTimestamp = true;
    securityElement.RecipientTokenParameters = new X509SecurityTokenParameters(X509KeyIdentifierClauseType.IssuerSerial, SecurityTokenInclusionMode.Never);
    securityElement.InitiatorTokenParameters = new X509SecurityTokenParameters(X509KeyIdentifierClauseType.IssuerSerial, SecurityTokenInclusionMode.AlwaysToRecipient);
    securityElement.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic128Rsa15;
    securityElement.SecurityHeaderLayout = SecurityHeaderLayout.Strict;
    securityElement.SetKeyDerivation(false);
    securityElement.EndpointSupportingTokenParameters.Signed.Add(userNameToken);
    securityElement.MessageProtectionOrder = System.ServiceModel.Security.MessageProtectionOrder.SignBeforeEncrypt;
    securityElement.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
    binding.Elements.Add(securityElement);
    var encodingElement = new TextMessageEncodingBindingElement();
    encodingElement.MessageVersion = MessageVersion.Soap11WSAddressing10;
    encodingElement.WriteEncoding = Encoding.UTF8;
    encodingElement.ReaderQuotas.MaxArrayLength = 50000000;
    encodingElement.ReaderQuotas.MaxStringContentLength = 50000000;
    binding.Elements.Add(encodingElement);
    var httpsElement = new HttpsTransportBindingElement();
    httpsElement.MaxBufferSize = 50000000;
    httpsElement.MaxReceivedMessageSize = 50000000;
    httpsElement.MaxBufferPoolSize = 50000000;
    httpsElement.UseDefaultWebProxy = true;
    binding.Elements.Add(httpsElement);
    return binding;
}

现在我不关心Action元素是否被签名,或者甚至它根本不存在,但是攻击响应以完全删除标记会导致'No 签名消息部分被指定为带有' Action '的消息。的例外。

我如何配置我的客户端以接受响应消息中的Action和其他寻址元素?或者,我可以将它们更改为什么以便WCF允许它们通过?

& # 39;行动# 39;& # 39;http://www.w3.org/2005/08/addressing& #

要覆盖用于身份验证的远程安全套接字层(SSL)证书的默认检查,请在客户端指定:

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; }); 

要调查证书错误,请检查RemoteCertificateValidationCallback委托(链接到MSDN手册页)的sslPolicyErrors参数。