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");
   }
4
  • Are the certificates TLS2 or TLS3? Commented Feb 10 at 10:29
  • Actually, restart of PC helped, however the real issue is signing outgoing messages Commented Feb 10 at 10:47
  • This is not a SSL/TLS issue since you are completing the connection. Certificates are used for different purposes and it makes perfect sense to have one certificate for TLS and another for signing. You may be having an issue with using wrong schema or wrong version of schema that does not work with the encryption mode of the certificate. There are many online tools that will sign xml with certificates that you can compare your results with the tools results. Signing is always tricky and usually websites give samples of the signed results to help you develop your own code. Commented Feb 10 at 13:28
  • Which binding you are using? Try BasicHttpsBinding if it's not. Commented Feb 11 at 10:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.