次の行のような 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シェルでうまく機能しますが、ここでは機能せず、エラーもスローされません。
何か案が?