如何在WCF服务上实现WS-Security

时间:2019-01-22 04:03:18

标签: wcf ws-security soapheader

基本上,我需要将asmx服务转换为WCF,因为我必须实现ws-security。我们在.net 4上有大量的asmx服务。但是我将其中一些升级到WCF。我有一个服务应该从客户端收到的请求的示例标头。

示例:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1"> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SIG-BEFF7CB55C69AB1BB5147624829678710"> <ds:SignedInfo> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"> <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="soap"/> </ds:CanonicalizationMethod> <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#gost34310-gost34311"/> <ds:Reference URI="#id-BEFF7CB55C69AB1BB514762482966309"> <ds:Transforms> <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"> <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList=""/> </ds:Transform> </ds:Transforms> <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#gost34311"/> <ds:DigestValue>d57ciD7pb509fbkviNryRDasdWJedT9NLo9DHfDTFIPKUE=</ds:DigestValue> </ds:Reference> </ds:SignedInfo> <ds:SignatureValue> mGJuAVI6uZoqxhITYLgM6lidMasdW368R+ksSsfRO9+tPEgy/f0j0M1TkH/bA7DVTqstH30q25qdH7fCDNsrmzfpA== </ds:SignatureValue> <ds:KeyInfo Id="KI-BEFF7CB55C69AB1BB514762482966307"> <wsse:SecurityTokenReference wsu:Id="STR-BEFF7CB55C69AB1BB514762482966308"> <wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"> MIIGzzCCBnigAwIBAgIasdgd85y+4K6Cxug5+mBUOLVm9VA== </wsse:KeyIdentifier> </wsse:SecurityTokenReference> </ds:KeyInfo> </ds:Signature> </wsse:Security> </SOAP-ENV:Header> <soap:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-BEFF7CB55C69AB1BB514762482966309"> ... some data ... </soap:Body> </soap:Envelope>

考虑到以上示例,我需要实现哪种编程验证和配置绑定? WS-Security对我来说是新的。任何给出正确方向的答案或示例都会有所帮助。

0 个答案:

没有答案