【问题标题】:Howto sign CSR using Openssl commands in a C# process如何在 C# 进程中使用 Openssl 命令签署 CSR
【发布时间】:2013-09-03 07:45:56
【问题描述】:

我已经能够通过 C# 进程使用 Openssl 命令生成密钥以及从密钥中生成 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 中工作正常,但在这里不起作用,也不会引发任何错误。

有什么想法吗?

【问题讨论】:

    标签: c# openssl certificate signing process.start


    【解决方案1】:

    我能够解决它,只需将 index.txt 和 serial.txt 移动到 bin 目录中。

    就是这样。

    【讨论】:

      猜你喜欢
      • 2013-05-15
      • 1970-01-01
      • 2022-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-21
      • 2020-06-02
      • 2015-04-08
      相关资源
      最近更新 更多