dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.64k stars 25.28k forks source link

Need C# Examples of How to Generate Certificates #26613

Open ijabit opened 2 years ago

ijabit commented 2 years ago

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.

blowdart commented 2 years ago

@bartonjs As the "be a CA" code is yours do you think it's worth giving a C# sample here?