我需要使用WS Security将NET Framework 4客户端应用程序连接到部署在Apache CXF上的Web服务。这项服务是我无法控制的。
该服务将作为“服务参考”添加到项目中。
这是代理:
ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf AcceptAllCertifications)
Dim oBinding As New CustomBinding()
Dim oSecurity As SecurityBindingElement
oSecurity = AsymmetricSecurityBindingElement.CreateCertificateOverTransportBindingElement(MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10)
oSecurity.IncludeTimestamp = True
oBinding.Elements.Add(oSecurity)
oBinding.Elements.Add(New CertFixEscapedComma.CertRefEncodingBindingElement())
( This a custom message encoder)
CertFixEscapedComma.CertRefEncoder.CERTIFICADO = Convert.ToBase64String(oCertificado.RawData)
oBinding.CloseTimeout = New TimeSpan(0, 2, 0)
Dim oTransport As New HttpsTransportBindingElement()
oBinding.Elements.Add(oTransport)
Dim oProxyClient As New NameServiceClient(oBinding, New System.ServiceModel.EndpointAddress(New Uri("https://url_service")))
Dim oCertificado As X509Certificate2
oCertificado = function_client_certificate() ' this get the proper cert
oProxyClient.ClientCredentials.ClientCertificate.Certificate = oCertificado
oProxyClient.name_function(params) 'call to the remote service
因此,在“ unwrappingToken = resolver.ExpectedWrapper”中,我得到一个“空”。
这可能是某种“消息名称空间不匹配”,或者类似的东西,我看不到吗?
证明还可以,并且有效。它具有x509v3的所有属性,并且发行者是受信任的发行者...
MMMHUHU
相关分类