我尝试用WS-Security规范编写java服务器的wcf客户端。有没有办法用C#中的程序以编程方式实现客户端(时间戳,用户名,加密和签名)
答案 0 :(得分:0)
您的帖子很难说明您的相应设置是什么。在这里,您使用了我使用的配置来使用使用ws-security的java Web服务。在我的情况下,我获得了客户端证书和我导出的服务,并从服务的站点安装证书。 对于您肯定会遇到的几个陷阱,请参阅this site 在下面用您的证书Thumbprint替换xx。 让我们知道您的进展。
<system.serviceModel>
<bindings>
<customBinding>
<binding name="MyBindingName" >
<textMessageEncoding messageVersion="Soap11"/>
<security authenticationMode="MutualCertificate" enableUnsecuredResponse="true" allowSerializedSigningTokenOnReply="true"
messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
includeTimestamp="true">
</security>
<httpsTransport />
</binding>
</customBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ClientCertificateBehavior">
<clientCredentials>
<clientCertificate findValue="xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx"
storeLocation="CurrentUser" storeName="My"
x509FindType="FindByThumbprint" />
<serviceCertificate>
<defaultCertificate findValue="xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx"
storeLocation="CurrentUser" storeName="My"
x509FindType="FindByThumbprint"/>
<authentication />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="https://YOURSERVICE_ADDRESS"
binding="customBinding" bindingConfiguration="MyBindingName"
contract="srvContract" name="srvContract" behaviorConfiguration="ClientCertificateBehavior">
</endpoint>
</client>
</system.serviceModel>