我正在为不受我控制的 Java Web 服务创建 WCF 客户端,并且遇到了问题,因为如果 Timestamp 标头元素已签名,该服务将返回 InvalidSecurity 错误。
我目前正在使用以下SecurityBindingElement
,但这会自动签署 Timestamp 元素。我怎样才能阻止这种行为?更一般地说,我如何控制哪些元素已签名,哪些未签名?
var version = MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10;
var sec = (AsymmetricSecurityBindingElement)SecurityBindingElement.CreateMutualCertificateBindingElement(version);
sec.EndpointSupportingTokenParameters.Signed.Add(new UserNameSecurityTokenParameters());
sec.MessageSecurityVersion = version;
sec.IncludeTimestamp = true;
sec.MessageProtectionOrder = MessageProtectionOrder.EncryptBeforeSign;