如何对我的 WCF 客户端服务调用进行签名和加密(来自规范:所有消息都应根据 WS-Security X.509 令牌配置文件进行签名和加密。可以在此处找到规范)。
我必须使用 SOAP 1.1 和 WS-Security,该服务是由第 3 方提供的,我很确定他们是使用 Java (IBM DataPower) 编写的(反正不是 WCf)。
我尝试了以下方法,但我认为这是提出错误问题的情况,因为我读过的大部分内容都说客户端不会决定加密什么,这是由服务保护级别(SignAndEncrypt)定义的。我还看到了对我应该用来加密的 X509SecurityToken 的引用,但是我认为这是较旧的 .net。
无论如何,这就是我到目前为止所拥有的:
' Create the binding.
Dim myBinding As New BasicHttpBinding() ' FOR SOAP 1.1
myBinding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential
myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate
myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate
' Create the endpoint address.
Dim ea As New EndpointAddress("https://removed")
' Create the client.
Dim starClientProxy As New wcfStarServiceProxy.starTransportPortTypesClient(myBinding, ea)
' Specify a certificate to use for authenticating the client.
starClientProxy.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "removed")
'Cert used for encryption
starClientProxy.ClientCredentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.CurrentUser, StoreName.AddressBook, X509FindType.FindBySubjectName, "removed")
所以现在它应该自动加密它?我找不到任何需要设置的东西
'call the service
Dim response As wcfStarServiceProxy.AcknowledgeRepairOrderPayload = starClientProxy.ProcessMessage(payload)
所以,我认为我已经成功签署了请求,但是,正文没有加密。如何加密正文?