March 15, 2024

Read TLS/SSL Certificate in Azure App Service from C# Code

Recently I was updating an old .NET Core web application to .NET 8 and the code was reading a certificate as follows. private X509Certificate2 GetCertificateByThumbprint(string thumbprint){    X509Store store = new (StoreName.My, StoreLocation.CurrentUser);    store.Open(OpenFlags.ReadOnly);   
December 6, 2023

ASP.NET Core 8.0: Securing Swagger UI Endpoints

With ASP.NET Core 8.0, now you can secure Swagger UI endpoints by calling MapSwagger().RequireAuthorization. Consider the following code example. WebApplicationBuilder builder = WebApplication.CreateBuilder(args); builder.Services.AddEndpointsApiExplorer();builder.Services.AddSwaggerGen(); builder.Services.AddAuthorization();builder.Services.AddAuthentication(“Bearer”