AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

Need C# Examples of How to Generate Certificates

Open ijabit opened this issue 3 years ago • 1 comments

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.

ijabit avatar Aug 02 '22 15:08 ijabit

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

blowdart avatar Aug 02 '22 16:08 blowdart