Yossi G.
Yossi G.

Reputation: 1151

Getting "Could not create SSL/TLS secure channel." on Windows Server 2012 R2

The following code runs just fine on my development workstation (Windows 10 Pro), running in Visual Studio. As you can probably guess from the naming convention, I am using WebClient to post to a remote https:// endpoint.

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
resp = m_WebClient.UploadValues(m_WebClient.BaseAddress, "POST", postParams);

However, when I deploy it to my production server (Windows Server 2012 R2 Datacenter - it's an Azure VM), I am trapping the following exception:

The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.WebClient.UploadValues(Uri address, String method, NameValueCollection data)
at System.Net.WebClient.UploadValues(String address, String method, NameValueCollection data)
at rater8.ReviewShake.Request.Processor.TryGetRESTApi(Int32 CompanyId, String ScrapeString, String LastJobId, String& Response)

I know that I am capable of communicating from my production server to the remote server because I've executed the call in Postman from the production server. I receive a 200 - OK. I know the remote server insists on TLS1.2, because if I disable that protocol in Postman, the call fails.

This is production code which has been running until just a couple of days ago. I will contact the vendor, but support can be spotty. In the meantime, does anyone have any ideas? Is there something which I need to configure at the OS level in order to enable this on Windows Server 2012? (I do have Windows Update running.) Thanks!

Since posting, I've accumulated two additional facts:

  1. Switching over to HttpWebRequest did not have any positive effect.
  2. Moving the executable over to another Windows 10 Pro machine did have a positive effect, the connection was successfully established.

So the critical combination of factors here which cause this to break is the combination of Windows Server 2012 R2 and my C# code (WebClient or HttpWebRequest). Recall that Postman was able to establish communication from the Windows Server so that, in and of itself is not the issue. Must be some esoteric handshake issue, but I'm running out of ideas. Thanks for any advice which you can provide!

Upvotes: 0

Views: 1657

Answers (1)

bennyB
bennyB

Reputation: 21

Currently dealing with the same thing. We were running a web api call on a 2012 R2 server, it was working but all of a sudden, it stopped working around the time of your post.

I would assume that this is a bug with Microsoft, however here are the current solutions that I am testing that make sense.

  1. Try another server install version, we noticed it was working with a 2016 server
  2. I've noticed that this issue generally came to fruition when microsoft released a new VS 2019 Update, maybe try another editor or downgrade your vs2019 ide?
  3. Maybe try downgrading your .NET framework version to something a bit more stable.

These are things I am currently testing, but the most definite one that is working is getting an install of 2016 server or 2019. Spinning up a new server install for short term period until the issue is fixed, might just be up your alley.

Edit:
At this time, the move to a updated server seems to have fixed the issue.

Upvotes: 1

Related Questions