我已经能够通过C#进程使用Openssl命令生成密钥以及从密钥中生成CSR,如下所示:
startInfo.Arguments = @"ecparam -out ....Certificatesclient.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 ....Certificatesclient.key -subj '' -outform pem -out ....Certificatesclient.req";
Console.WriteLine("Generating CSR ");
System.Diagnostics.Process.Start(startInfo).WaitForExit();
Console.WriteLine("CSR generated");
然而,我不能从上面的代码生成SCR使用这个代码:
startInfo.Arguments = @"ca -batch -keyfile ....caca.key -cert ....cacacert.pem -in ....Certificatesclient.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,当命令被执行时,看看哪里出了问题,但我不知道怎么做。正如我所说,签名命令在opensslshell中运行良好,但它在这里不起作用,也不会引发任何错误。
知道吗?
我能够解决它,只需将index.txt和serial.txt移动到bin目录中。
就是这样。