使用C#执行GnuPG时发生超时事件

时间:2016-09-02 14:38:57

标签: c# encryption gnupg openpgp

我正在对数百万个文件运行解密过程,而我正在使用GnuPG。

作业运行几分钟后,它突然关闭,出现以下错误:

ERROR: Starksoft.Aspen.GnuPG.GpgException: Error.  Action: Decrypt.  Command args: --passphrase-fd 0 --no-verbose --batch --trust-model always --decrypt  ---> Starksoft.Aspen.GnuPG.GpgException: A time out event occurred while executing the GPG program.
   at Starksoft.Aspen.GnuPG.Gpg.ExecuteGpg(ActionTypes action, Stream inputStream, Stream outputStream)
   --- End of inner exception stack trace ---
   at Starksoft.Aspen.GnuPG.Gpg.ExecuteGpg(ActionTypes action, Stream inputStream, Stream outputStream)
   at Starksoft.Aspen.GnuPG.Gpg.Decrypt(Stream inputStream, Stream outputStream)

我写了一份批处理作业并试图安排它,几分钟后也失败了。如果我需要更改任何超时设置,我在GnuPG文件夹中看不到配置文件。

1 个答案:

答案 0 :(得分:0)

GnuPG没有超时。超时由您正在使用的Starksoft.Aspen GnuPG C#接口触发。查看代码,似乎default timeout is 10 seconds和超时可以是configured through setting the TimeOut property。我不习惯C#和那个框架,但它似乎归结为类似

gpg.TimeOut = 120000; // Set timeout to 120 seconds

阅读Process.WaitForExit(Int32)上的MSDN文档,似乎超时值Int32.MaxValue将完全禁用超时:

gpg.TimeOut = Int32.MaxValue; // Disable timeout