0

I am trying to make a post request from a https to another https. I have ordered and installed a certificate with private key, and the certificate is installed in Personal and Trusted Root Certification Authorities for both Current User and Local Computer.

I have googled, read and tried many solutions from The request was aborted: Could not create SSL/TLS secure channel and other websites. Nothing is working for me. I'm always getting "The request was aborted: Could not create SSL/TLS secure channel"

I am using .Net Framework 4.7.1, and my code is the following

 public async Task<HttpResponseMessage> PostAsync<T>(T arg, string uri)
        {
            var handler = new WebRequestHandler();
            var client = new HttpClient(handler);
            try
            {
                var content = CreateJsonContent(arg);
                var processResult = await client.PostAsync(uri, content);
                return processResult;
            }
            catch (Exception exception)
            {
                throw;
            }
            finally
            {
                client.Dispose();
            }
        }

All help is highly appreciated

bombo
  • 1,781
  • 6
  • 22
  • 25
  • What certificate are you talking about? Server? Client? Before Googling, give yourself a clear summary of what exactly is the issue you are attacking, or you are simply lost in the sea of information. – Lex Li Aug 10 '18 at 13:03
  • @LexLi thank you for your comment. I have installed Client certificates. I am not lost in the sea of information, but I have run out of solutions to the problem of why am I able to contact the service test environment, but when trying to contact the production environment with the same code I am getting this exception – bombo Aug 13 '18 at 09:22
  • You are far from "running out of solutions", because you didn't yet start to know enough of the problem. The error message "The request was aborted: Could not create SSL/TLS secure channel" requires you to dig into SSL/TLS handshakes when any failure happens, as that's the most efficient way to know the exact cause. Change the direction of your Googling to learn that (tools like Wireshark), and then you should be able to move forward. Never blindly keep trying solutions if the first few do not help. That usually means you hit a really complex one. – Lex Li Aug 13 '18 at 13:21
  • Thanks again @LexLi, I'll be looking at Wireshark and try to learn more about SSL/TLS handshaking, I'll keep you posted – bombo Aug 14 '18 at 09:28

0 Answers0