从 MVC 应用程序使用 Pgp.exe

发布于 2024-11-26 11:56:14 字数 1142 浏览 1 评论 0原文

我的任务是将遗留应用程序转换为 mvc。该应用程序使用 pgp.exe 对用户输入进行 pgp 签名并将其作为电子邮件发送。该应用程序可以在本地和测试服务器上运行,但不能在实时服务器上运行。我不得不跳过一些麻烦,例如在应用程序池中运行指定的用户,以便我们可以在用户配置文件中设置密钥,但它有效。

由于某种原因,在运行服务器(Windows 2003 IIS 6)上并且与测试服务器相同时,它失败了。问题是 pgp.exe 似乎不会签署和创建我从控制台输出得到的消息。 “签名错误”??当我将命令放入以应用程序池用户身份登录的 shell 窗口中时,它运行没有问题(在与某些权限进行斗争之后),但是当通过 mvc 应用程序/IIS 服务器运行时,它会失败。用于调用该过程的代码如下。

        var startInfo = new ProcessStartInfo();
        startInfo.FileName = _pgpexeLocation;

        //startInfo.FileName = "pgp.exe";
        startInfo.Arguments = string.Format("-sta \"{0}\" -u keyuser-z keypass +COMPATIBLE +FORCE", _tempFilePath);

        startInfo.UseShellExecute = false;
        startInfo.RedirectStandardOutput = true;
        startInfo.LoadUserProfile = true;

        using (Process exeProcess = Process.Start(startInfo))
        {
            // TODO: set limit to wait for and deal with exit
            exeProcess.WaitForExit();

            //var stringItem = exeProcess.StandardOutput.ReadToEnd();
            //Logger.Info(stringItem);
        }

我在这里紧紧抓住救命稻草,希望有人以前做过类似的事情并且可以提供帮助。我猜这是关键位置或文件位置没有在某个地方被拾取,但不确定还可以尝试什么?

I've been tasked with converting a legacy application to mvc. The app used pgp.exe to pgp sign user input and send it as an email. The application works locally and on a test server but won't run on a live server. I've had to jump though hoops such as running a specified user in the application pool so that we can set the keys in the users profile BUT it worked.

For some reason on the live server which is windows 2003 IIS 6 and identical to the testing server it fails. The problem is pgp.exe just wont seem to sign and create files the message I get from the console out put is. "Signature Error"?? When I put the command into a shell window logged in as the app pool user it runs no problem (after a fight with some permissions) but when running through the mvc application/IIS server it fails. The code used to call the process is below.

        var startInfo = new ProcessStartInfo();
        startInfo.FileName = _pgpexeLocation;

        //startInfo.FileName = "pgp.exe";
        startInfo.Arguments = string.Format("-sta \"{0}\" -u keyuser-z keypass +COMPATIBLE +FORCE", _tempFilePath);

        startInfo.UseShellExecute = false;
        startInfo.RedirectStandardOutput = true;
        startInfo.LoadUserProfile = true;

        using (Process exeProcess = Process.Start(startInfo))
        {
            // TODO: set limit to wait for and deal with exit
            exeProcess.WaitForExit();

            //var stringItem = exeProcess.StandardOutput.ReadToEnd();
            //Logger.Info(stringItem);
        }

I'm clutching at straws here hoping somebody has done something similar before and can help. I'm guessing it's key location or file location not being picked up somewhere but not sure what else to try?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

皓月长歌 2024-12-03 11:56:15

事实证明,即使应用程序池使用特定用户,并且当我检查底层进程调用时,我会在该用户的应用程序数据文件夹中设置密钥,但它实际上是在尝试从默认用户配置文件中获取密钥。不确定这是否是 IIS 配置或类似的配置,但将密钥和 pgp 文件夹移动到此应用程序数据是否有效?

Turns out that even though the app pool was using a specific user and I'd set the keys up in that users appdata folder when I checked the underlying process call it was actually trying to pick the keys up from the Default User profile. Not sure if this was an IIS config or something similar but moving the keys and pgp folder to this appdata instead worked?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文