I'm upgrading a Visual C++/CLI MFC DLL so that TLS 1.2 is used by default in order to comply with the requirement soon to be enforced Authorize.Net.
The DLL is now set to target .NET 4.7 and .NET 4.7 is installed on the Windows 10 machine it runs on, but TLS 1.2 is not enabled by default, as it should be with .NET 4.6 and above.
I'd like to avoid having to modify the DLL with the code:
ServicePointManager::SecurityProtocol = SecurityProtocolType::Tls12;
I tested compatibility with TLS 1.2 by using the following code, which always throws an exception:
HttpWebRequest ^httpReq = (HttpWebRequest ^)(WebRequest::Create("https://www.ssllabs.com:10303"));
HttpWebResponse ^ httpResp = (HttpWebResponse ^)httpReq->GetResponse();
if (((int)httpResp->StatusCode >= 200) &&
((int)httpResp->StatusCode <= 299))
{
// Log message indicating success
}
I found the default security protocol by using:
int protocolType = (int)ServicePointManager::SecurityProtocol;
which returned a value of 240, indicating:
SecurityProtocolType.Tls | SecurityProtocolType.Ssl3
A different version of the DLL, written in C# & targeted to .NET 4.6, targets TLS 1.2 by default on Windows Server 2012 R2 with .NET 4.6 installed, without having to explicitly set the SecurityProtocol via the ServicePointManager.
Why wouldn't TLS 1.2 be enabled by default for the DLL on the Windows 10 system if everything targets & runs .NET 4.7? Could it have something to do with the fact the DLL is C++/CLI and being called by an older VB6 application? I'm simply perplexed.