Skip to content

Instantly share code, notes, and snippets.

Last active April 14, 2021 10:00
What would you like to do?
Azure App Service: Load certifcate
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
public static class CertificateExtensions
// Private certificatePath: $"/var/ssl/private/{thumbprint}.p12"
// Public certificatePath: $"/var/ssl/certs/{thumbprint}.der"
public static X509Certificate2 LoadCertificate(string thumbprint, string certificatePath)
if (string.IsNullOrWhiteSpace(thumbprint))
throw new ArgumentNullException(nameof(thumbprint));
if (string.IsNullOrWhiteSpace(certificatePath))
throw new ArgumentNullException(nameof(certificatePath));
var bytes = File.ReadAllBytes(certificatePath);
var certificate = new X509Certificate2(bytes);
return certificate;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment