使用邮件安全性的WCF服务TLS握手
问题描述:
我正在尝试实现自定义WCF服务客户端。服务器使用wsHttpBinding和消息安全性,没有客户端凭据。我必须通过编程来形成适当的肥皂信封才能开始TLS握手。我已经从标准的WCF客户端获取了初始请求。消息是这样的:使用邮件安全性的WCF服务TLS握手
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
<a:MessageID>urn:uuid:f88d1721-29ce-4418-994e-a3796f053e63</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://localhost:56635/Service1.svc</a:To>
</s:Header>
<s:Body>
<t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" Context="uuid-6549ee11-0349-4dbc-8686-6b7f0b079251-1">
<t:TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</t:TokenType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:KeySize>256</t:KeySize>
<t:BinaryExchange ValueType="http://schemas.xmlsoap.org/ws/2005/02/trust/tlsnego" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">FgMBAFoBAABWAwFPQ8mbvU/nL8Cgu/CRIhhvVyRAYNdppNpdUY2UEi/GLQAAGAAvADUABQAKwBPAFMAJwAoAMgA4ABMABAEAABX/AQABAAAKAAYABAAXABgACwACAQA=</t:BinaryExchange>
</t:RequestSecurityToken>
</s:Body>
</s:Envelope>
问题是,我找不出我应该编码和插入到BinaryExchange标记的值。任何帮助,将不胜感激。
答
你不想走那条路。有两个复杂的标准(ws-secureconversation和ssl nego)。每个包含多个消息交换。您需要非常努力地完成所有签名和加密的部分。您应该使用常规的WCF客户端。