How can I create a self-signed certificate using C#?
Since .NET 4.7.2 you can create self-signed certs using System.Security.Cryptography.X509Certificates.CertificateRequest. For example: using System; using System.IO; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; public class CertificateUtil { static void MakeCert() { var ecdsa = ECDsa.Create(); // generate asymmetric key pair var req = new CertificateRequest(“cn=foobar”, ecdsa, HashAlgorithmName.SHA256); var cert = req.CreateSelfSigned(DateTimeOffset.Now, DateTimeOffset.Now.AddYears(5)); // Create PFX (PKCS #12) with … Read more