我已经能够使用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中工作正常,但它在这里不起作用,并且不会抛出任何错误。
有什么想法吗?
答案 0 :(得分:0)
我能够解决它,只需将index.txt和serial.txt移动到bin目录中。
就是这样。