我有一个 WCF 客户端代理,并使用以下绑定(bind)元素对第三方 Java Web 服务的请求进行签名:
Dim asec As TransportSecurityBindingElement = SecurityBindingElement.CreateCertificateOverTransportBindingElement()
asec.EnableUnsecuredResponse = True
asec.SetKeyDerivation(False)
asec.AllowInsecureTransport = True
asec.IncludeTimestamp = True
但是,我被告知服务端存在验证错误:
Signature validation failed: Invalid encoding type (only base64 is supported) for token:uuid-168b7c90-2d6a-4928-9979-94cb84443d3b-1
所以我假设我需要将某些内容(可能是签名?)设置为 base64 编码。我怎样才能做到这一点?
最佳答案
要回答您的答案中的问题:
Though I don't know why this works, or what it means.
SecurityBindingElement.CreateCertificateOverTransportBindingElement()
将绑定(bind)的 MessageSecurityVersion 初始化为其默认值,即:
WS-Security 1.1, WS-Trust of February 2005, WS-SecureConversation of February 2005 and WS-SecurityPolicy 1.1.
通过您现在调用的重载,您可以指定:
Basic Security Profile 1.0 based on WS-Security 1.0, WS-Trust of February 2005, WS-SecureConversation of February 2005 and WS-SecurityPolicy 1.1 security specifications.
要确定 WCF 实际发出的 EncodingType,您必须在中间放置一个 HTTP 监视器(例如 Fiddler),或者让 .NET 输出跟踪信息来记录正在发送的消息。您还可以访问或请求服务器日志以了解服务器认为该消息无效的原因。
但是,我怀疑,鉴于对实际错误消息的某些 Web 搜索,Java 服务器会提示您的 WCF 客户端省略 上的 EncodingType=...#Base64Binary
wsse:BinarySecurityToken
。根据spec ,这是唯一允许的值(如果双方都同意,则为自定义值),并且它未标记为可选。
将 MessageSecurityVersion 更改为 WS-sec 1.0 后,如所解释的那样 here (这很容易找到 - 一旦您知道自己在寻找什么),我想 WCF 显式输出 EncodingType
属性,使服务接受消息。
关于vb.net - 如何获取WCF请求的base64签名编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20399257/