Вопрос

I have been able to generate keys as well as generate CSR out of the keys through a C# process using an Openssl command like the following line:

   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");

However, I could not the SCR generated from the above code using this code:

        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"); 

     }

I tried to debug Openssl in VS2012 when commands are executed to see what goes wrong but I did not know how to do it. As I said the signing commands works fine in the openssl shell but it does not work here and it does not throw any error.

Any idea?

Это было полезно?

Решение

I was able to solve it, just move index.txt and serial.txt into the bin directory.

That's it.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top