I have a web app hosted on Microsoft Azure that includes a Web API. I am targeting .NET Framework 4.5.
I am working through all the required steps in order to make TLS 1.2 the minimum version required for incoming requests.
Before I officially switch to TLS 1.2 minimum for incoming requests, I would like to know if anyone is currently using older TLS versions, since we have third parties using our API.
Is there a way to detect the TLS version that was negotiated in a specific API request?
For example, I have this API call below. What code can I write using .NET Framework 4.5 that will get the TLS version that was negotiated?
[HttpGet]
[Authorize(Roles = "User")]
public HttpResponseMessage GetFirstName()
{
// I would like to add code here to get TLS version negotiated so I can log it
var email = User.Identity.GetUserName();
ApplicationUser userFound = GetUserByEmail(email);
if (userFound == null)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Error: No such user.");
}
var firstName = new { FirstName = userFound.FirstName };
return Request.CreateResponse(HttpStatusCode.OK, firstName);
}
I know I eventually need to upgrade .NET Framework altogether, but I need a quick solution on 4.5 before I can tackle that.
Absolutely, Panagiotis Kanavos point is valid. Upgrading to a supported version of .NET Framework, such as 4.6.2 or later may help more.
As you can check here in MS doc saying that if you are using 4.5v you need to upgrade for the latest version.
I have tried for the newer version of .NET Framework 4.6.1. I can access the TLS version information directly from the
SslStreamclass.SslStream.SslProtocolproperty is used to get the negotiated TLS version. TheAuthenticateAsServermethod is called to authenticate the server side of the connection.