Hi, I'm trying to find out how to secure my Blazor app using Entra with a certificate. I've been googling and youtubing for hours and have found endless guides on how to autheniticate using clientID/secret, but due to security that method isn't an option for me.
My app is a Blazor app, in interactive server mode. The app will be accessed by humans as well as an automated device that has scripting capability and can use a certificate. The app is currently working fine and hosted in IIS on an on-premises server. My next step is to secure it, in particular the API will be exposed to a client outside our organisation. By API I mean specifically that I've added minimal API methods into the Blazor app that perform the same functions as the UI.
I've seen how to protect my razor pages using [Authorize] and to use the identity class to secure my API, that part I should be able to work out. My question is about how to authenticate the user in the first place, so that those protection methods can then work.
I want to use Azure Entra to handle the authentication, and I already have an app registered in my organisations Azure Portal. My understanding is that our client will supply a certificate to us, we install it in Azure, and when they access the API they supply the private key part of the certificate which we authenticate against the public key.
I'm looking for a guide or tutorial that explains how to do this, if anyone can suggest one?
Thanks
Rajesh GamiPosted Nov 20, 2025, 7:42 AM
? Using Azure Entra ID
? Registering the Blazor app
? Configuring certificate-based authentication
? Using MSAL
? Calling secured APIs
? Best practices for production
I’ve included both Blazor Server and Blazor WebAssembly flows where applicable.
1. Understanding the Authentication Flow
Azure Entra ID supports two authentications:
A) User Authentication (OpenID Connect)
When the app signs in users with Azure AD.
B) App Authentication (Client Credential Flow using Certificate)
App authenticates itself using a certificate.
You can combine both:
Users sign in using Azure AD
App (Blazor) calls downstream APIs using certificate-based client credentials
This is the most common enterprise setup.
2. Azure Setup (Required)
Step 1: Register Two Apps
You need:
(1) Blazor App Registration
For user login.
Redirect URIs:
Also add logout:
(2) API or Protected Resource Registration
Or even Microsoft Graph.
This app will have:
Client ID
Tenant ID
Expose API Scopes
Certificate-based credentials (Upload Certificate)
3. Upload Certificate to Entra ID
Go to:
Azure Portal ? App Registrations ? (API App) ? Certificates & Secrets ? Upload Certificate
Upload
.cer(public certificate)Private
.pfxis stored only in your Blazor app (never upload).4. Configure Blazor App to Use Certificate Authentication
For Blazor Server, use Microsoft.Identity.Web.
Install:
5. Configure
appsettings.json6. Register Authentication in
Program.cs(Blazor Server)7. Certificate Loader Utility
8. Token Acquisition Service (using MSAL)
9. Calling API from Blazor using Certificate-based Token
10. For Blazor WebAssembly (WASM)
WASM cannot securely store a certificate ? you must use:
? Backend API / BFF (Backend-for-Frontend pattern)
? Or Azure API Management
The certificate-based authentication must happen on server side, not in browser.
WASM can only do user authentication, not certificate authentication.
11. End-to-End Flow
User Login Flow (OIDC)
User ? Blazor App ? Azure AD ? ID Token ? Authenticated in UI
App-to-App Flow (Certificate)
Blazor App ? Certificate ? Azure AD Token Endpoint
? Access Token ? Call Downstream API
12. Recommended Architecture
13. Security Best Practices
? Use PFX with password
? Store certificate in Azure Key Vault (Recommended)
? Rotate certificates every 6–12 months
? Never store cert in GitHub
? Use
.defaultscope for client credentials