C#函数可以使用预填充参数运行OpenSSL X509证书生成命令,因此用户不需要与之互动?
我会使用一个C#函数,该函数将通过执行OpenSSL命令来生成X509证书。我找到了这篇文章:执行来自c#的多个命令提示符命令,这非常有用,所以我的功能看起来像这样的东西:
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
}
}
但是对我来说,我试图生成x509证书=>
- 首先,我正在将私钥生成一个文件privkey.key。
- 然后我执行openssl命令' req -new -new -sha256 -key privkey.key -out cert.csr.csr '以生成csr证书,和执行此操作时,会有一个提示要求您提供国家名称,州/省,密码等:
- < img src =“ https://i.sstatic.net/kgux9.png” alt =“ list item”>
所以我的问题是,是否可以使用预填充参数运行此命令需要与之互动吗?在我的c#函数中,我将如何编写这些提示的答案,并执行命令在不响应提示的情况下为提示提供答案的命令?
提前致谢!!
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!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论