我已经能够使用 Openssl 命令生成密钥以及通过 C# 进程从密钥中生成 CSR,如下行:
startInfo.Arguments = @"ecparam -out ..\..\Certificates\client.key -name secp521r1 -genkey ";
try
{
Console.WriteLine("Generating keys...");
System.Diagnostics.Process.Start(startInfo).WaitForExit();
Console.WriteLine("Keys generated");
startInfo.Arguments = @"req -new -nodes -key ..\..\Certificates\client.key -subj '' -outform pem -out ..\..\Certificates\client.req";
Console.WriteLine("Generating CSR ");
System.Diagnostics.Process.Start(startInfo).WaitForExit();
Console.WriteLine("CSR generated");
但是,我无法使用以下代码从上述代码生成 SCR:
startInfo.Arguments = @"ca -batch -keyfile ..\..\ca\ca.key -cert ..\..\ca\cacert.pem -in ..\..\Certificates\client.req -outform PEM -out client.pem";
Console.WriteLine("Signing Cert...");
System.Diagnostics.Process p= System.Diagnostics.Process.Start(startInfo);
//This step is executed without error but does not generate the signed certificate client.pem.
//Strangely enough, this command works fine when executed in the openssl shell and it does generate the signed client.pem
p.WaitForExit();
Console.WriteLine("Signing done");
}
执行命令时,我尝试在 VS2012 中调试 Openssl 以查看出现了什么问题,但我不知道该怎么做。正如我所说,签名命令在 openssl shell 中工作正常,但在这里不起作用,也不会引发任何错误。
任何想法?