.NET MAUI › Security & Authentication
How do you enforce SSL/certificate pinning in MAUI?
IntermediateAnswer
Validate the server certificate in the HttpClient handler by comparing its public key/thumbprint to a pinned value, rejecting mismatches. Configure via HttpClientHandler.ServerCertificateCustomValidationCallback (or platform handlers). Pinning defends against MITM but requires a rotation plan when certs change.
var handler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (m, cert, chain, e) =>
cert!.GetCertHashString() == PinnedThumbprint
};Real-world example A finance app pins its API certificate so a compromised network CA can't intercept traffic.