Dynamics 365, TLS 1.2 and How to Fix Your Apps

TLS, “Transport Layer Security” is a protocol that provides privacy between 2 applications. TLS has two layers, 1) TLS Record Protocol, which provides security, and 2) TLS Handshake Protocol, which allows the apps to authenticate. TLS 1.2 is the latest release. As the specification states:

The primary goal of the TLS protocol is to provide privacy and data
integrity between two communicating applications.

TLS is supported by the Microsoft .NET Framework in the following ways:

.NET 4.0 supports TLS 1.0

.NET 4.5+ supports TLS1.2 through a code update shown below

.NET 4.6+ supports TLS 1.2 by default

It is important to be on higher versions of TLS as older versions are subject to exploits. If your .NET code is running older versions of TLS, and the apps you are integrating with use newer protocols, you will run into errors.

In this post we will simulate getting an error trying to use a TLS version lower than TLS 1.2, running against Dynamics 365 version 9.0 and the ways to fix it. You can read more about the Dynamics 365 update to TLS 1.2 on the Microsoft website here.

Simulating the Problem

First, create a new Console app:

Change the .NET version to 4.5.2:

Now add code. We will do something simple, like connecting to Dynamics 365 and getting the version: