首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

B2B中的WCF,怎么用WCF开发一个只需签名不加密的网络服务(Secured Web Service)

2013-09-26 
B2B中的WCF,如何用WCF开发一个只需签名不加密的网络服务(Secured Web Service)WCF 包装过度,选项太多,一旦

B2B中的WCF,如何用WCF开发一个只需签名不加密的网络服务(Secured Web Service)

WCF 包装过度,选项太多,一旦涉及安全,非常的难,反复了才搞出好几次只需签名不加密的网络服务。因为错误信息不够详细甚至误导。微软经常夹带私货,无视真正的企业需求,例如和java实施的安全网络服务互通,通常java实施的安全网络服务互通只需HTTPS和X.509签名。但是微软就是不告诉你如何实现这个,整天扯他妈的wsHttpBinding,网上都是一般东抄西抄的关于wsHttpBinding教学材料或者混蛋,非常难以找到用WCF去实习只需签名的网络服务的材料,气得你半死。我觉得wsHttpBinding用途不是很大,是微软的私货。

有两点折磨了我好长时间,因为断断续续的实用WCF,半桶水晃荡。

1)PeerTrust:The certificate is valid if it is in the trusted people store. 我把它记成Personal Store即 My,老遇到 至少有一个Certificate无效的问题,困恼了很长时间。

2)千万不要用“using” 配合WCF Channel/Client/ChannelFactory,出错时真的是误导啊!痛心不已!

要不然出错时老出这个恶心的误导:

HTTP/1.1 200 OKContent-Type: text/xml; charset=utf-8Server: Microsoft-IIS/7.0X-Powered-By: ASP.NETDate: Mon, 23 Sep 2013 21:54:54 GMTContent-Length: 1862<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">    <s:Header>        <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">            <u:Timestamp u:Id="uuid-bd361f67-714a-4deb-8f9c-8a7d8954a8ef-1">                <u:Created>2013-09-23T21:54:54.197Z</u:Created>                <u:Expires>2013-09-23T21:59:54.197Z</u:Expires>            </u:Timestamp>            <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">                <SignedInfo>                    <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>                    <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>                    <Reference URI="#_1">                        <Transforms>                            <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>                        </Transforms>                        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>                        <DigestValue>EVvi+44ZpmFe3H+0tz7MfNmrHyI=</DigestValue>                    </Reference>                    <Reference URI="#uuid-bd361f67-714a-4deb-8f9c-8a7d8954a8ef-1">                        <Transforms>                            <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>                        </Transforms>                        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>                        <DigestValue>M6CgzU5+kM8WBslUdy2Xr9v4TJY=</DigestValue>                    </Reference>                </SignedInfo>                <SignatureValue>VCb5v4zi3+YA2PCyfUWkSUKQXEInYkqBJivmzRK5jWGEpsJ3ZJfqkzAfk3//eWjT38vrHGGgUJwQRkPWLW69M7ue3S4Tn8UpNcyI2IzbklIoJBjCVtdwP7BqRsDwHRGsynJXHhNSHSllzLrTnWNs9fPH1aSvqOKhuNHgfMlNBcU=</SignatureValue>                <KeyInfo>                    <o:SecurityTokenReference>                        <X509Data>                            <X509IssuerSerial>                                <X509IssuerName>CN=Root Agency</X509IssuerName>                                <X509SerialNumber>-32031604220717131174929833209954748223</X509SerialNumber>                            </X509IssuerSerial>                        </X509Data>                    </o:SecurityTokenReference>                </KeyInfo>            </Signature>        </o:Security>    </s:Header>    <s:Body u:Id="_1">        <GetDataResponse xmlns="http://tempuri.org/">            <GetDataResult>You entered: 1</GetDataResult>        </GetDataResponse>    </s:Body></s:Envelope>
本文乃硬座宝发明人原创,如需转载请一定注明原文作者 硬座宝发明人 也。


1楼suannai03146分钟前
您的文章已被推荐到博客首页和个人页侧边栏推荐文章,感谢您的分享。

热点排行