AspNetCore.Docs
AspNetCore.Docs copied to clipboard
Need C# Examples of How to Generate Certificates
The PowerShell examples of how to generate certificates are helpful, but it took me a week or two to figure out how to produce the equivalent C# code which generates client certificates signed by the root CA. I had to combine articles across StackOverflow, blog posts, and CodeProject articles to create a function which reproduces what the PowerShell command does. Here is a repro of the exact code needed in my case, and it's not easy as you can see. Generating these certificates via C# requires in-depth research into certificate and even the binary codes used to generate certain extensions. It would be great for MS to document this process or even build a library to streamline this and make it similar to the inputs and outputs of the PowerShell commands. Here is my runnable code which reproduces the PowerShell commands here:
https://dotnetfiddle.net/L8bwzO
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 35b7960d-6de5-78ee-bc45-d7218239bbc8
- Version Independent ID: d2db534b-198a-dc99-5b5a-0525582d39ac
- Content: Configure certificate authentication in ASP.NET Core
- Content Source: aspnetcore/security/authentication/certauth.md
- Product: aspnet-core
- Technology: aspnetcore-security
- GitHub Login: @blowdart
- Microsoft Alias: bdorrans
@bartonjs As the "be a CA" code is yours do you think it's worth giving a C# sample here?