I would like to gain more information of a current TLS/SSL request in an ASP.NET Core MVC Controller.
using Microsoft.AspNetCore.Mvc;
namespace WebApp.Controllers
{
public class HomeController : Controller
{
public IActionResult About()
{
if (HttpContext.Request.IsHttps)
{
// How to get more information about the transport layer ?
ViewData["Message"] = "Connection via TLS/SSL - ... missing details ...";
}
return View();
}
}
}
Is there a way to access the properties like used TLS version, cipher and so on ?
I know that this is not possible in ASP.NET MVC as stated in Check ssl protocol, cipher & other properties in an asp.net mvc 4 application. Perhaps the new framework with Kestrel offers this kind of information I was not able to find so far.
You can get those values using the Features
property from the HttpContext
.
If you call:
var tlsHandshakeFeature = request.HttpContext.Features.Get<ITlsHandshakeFeature>();
ITlsHandshakeFeature will give you the TLS version (Protocol property), the CipherAlgorithm, among many other things.
You can also Get
the ITlsConnectionFeature which will give you the certificates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With