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:
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.