提问人:Fernando 提问时间:8/18/2023 更新时间:8/18/2023 访问量:25
C# 使用证书、用户和密码调用 SOAP Web 服务
C# Call SOAP webservice with certificate, user and password
问:
我正在尝试调用一个旧的SOAP Web服务,该服务需要连接上的证书+用户和密码 这是我的尝试:
X509Certificate2 cert = new X509Certificate2("cert.p12", "h/K3+7NpiY", X509KeyStorageFlags.Exportable);
WSHttpBinding binding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential);
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
EndpointAddress endpointAddress = new System.ServiceModel.EndpointAddress("https:URL");
SOAPClient1 client= new SOAPClient1(binding, endpointAddress);
client.ClientCredentials.ClientCertificate.Certificate = cert;
client.ClientCredentials.UserName.UserName = "user._.1";
client.ClientCredentials.UserName.Password = "n6k5\">rvdR";
client.ChannelFactory.Credentials.ClientCertificate.Certificate = cert;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
我得到了
{“身份验证失败,因为远程方发送了 TLS 警报:'176'。
证书是正确的,我通过soap-ui将它与凭据一起使用,一切正常。
我尝试了不同的绑定选项,但没有成功
答: 暂无答案
评论