I wand to have a C# function that would generate x509 certificate by executing openssl commands. I found this post: Execute multiple command prompt commands from c#, which was very helpful,so my function will look like something like this:
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
using (StreamWriter sw = cmd.StandardInput)
{
if (sw.BaseStream.CanWrite)
{
sw.WriteLine("openssl genrsa -aes256 -out E:\\testing_folder\\test_file_com.key.pem 2048");
//other openssl commands
}
}
but for me, I am trying to generate the x509 certificate =>
- First, I am generating private key as a file privkey.key
- Then I am executing the openssl command 'req -new -sha256 -key privkey.key -out cert.csr' to generate csr certificate, and when executing this, there is a prompt asking you for country name, state/province, password, etc.:
So my question is,Is it possible to run this command with a prefilled parameter so the user does not need to interact with it? in my C# function, how would I write answers to these prompts and execute the commands feeding the answers to the prompts without having the user respond to the prompts?
Thanks in advance!!