最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - WcfClient - SSLTLS secure channel issue - Stack Overflow

programmeradmin3浏览0评论

I am using WCF client to send request to a government API. They gave 2 certificates, the one for 2 way authentication and encryption of SOAP messages, and the other for encryption of outgoing SOAP messages. The problem is that no matter how I try to add these certificates, I am getting SSL error.

If I try with postman, or directly with browser, I can make a call, since I have installed certificates on local machine, so they are working fine.

I tried this:

_wcfClient = new WcfClient();
  _wcfClient.ClientCredentials.ClientCertificate.Certificate = 
  CertificateManager.GetCertificate("certificate");

  var response = await _wcfClient.CheckDataAsync();

Also, I just wanted to test with HttpClient without checking server certificate, but still unsuccesfull

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

   var handler = new HttpClientHandler();
   handler.ClientCertificateOptions = ClientCertificateOption.Manual;

   ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;

   using (var httpClient = new HttpClient(handler))
   {
       httpClient.BaseAddress = new Uri("https:.....");

       var respons222e = await httpClient.GetAsync("test");
   }
发布评论

评论列表(0)

  1. 暂无评论