如何簽名和加密我的WCF客戶端服務調用(從規範:所有消息都應簽署並加密,對應於WS-Security X.509令牌配置文件,規範可見here)。如何讓我的WCF客戶端加密我的請求的SOAP Body?
我必須使用SOAP 1.1和WS-Security,服務由第三方提供,我非常肯定他們使用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)
所以,我覺得我已經成功地對請求籤名,但是,身體不加密。我如何加密身體?
這是有幫助的,謝謝。我需要使用X509SecurityTokenParameters,因爲我使用的是證書,而不是用戶名密碼。我使用了這個綁定,但是SOAP體仍然沒有加密。 –
@MrShoubs而不是'TransportSecurityBindingElement'嘗試'AsymmetricSecurityBindingElement'併發回 –
你知道有關這方面的好文章嗎?我不知道我在做什麼。現在我有一條消息:AsymmetricSecurityBindingElement無法構建通道或偵聽器工廠。 InitiatorTokenParameters屬性是必需的,但未設置。我不知道如何設置它。 –