We have an ASP app which compiles Silverlight DLLs and shoves them in a Xap package. The ASP app then needs to sign the Xap package with a certificate for elevated trust to work. This is done by calling signtool.exe. This has been working without a problem, but it stopped working once I started using ASP.Net impersonation. For those who are unfamilar, impersonation simply allows the ASP app to talk to the hard drive or network file structure as the impersonated user. Signtool now fails with an exit code of 1. I don't get any error to explain what is going wrong.
This is the line in web.config which causes impersonation to work
<identity impersonate="true" userName="[...]" password="[...]" />
So, the most obvious issue would be a security issue right? You would think that its an issue where the impersonated user doesn't have access to run signtool.exe. Well, what I did to rule this out was to copy the command line that is being executed by the ASP app, and then run this as the impersonated user. I physically logged on to my machine as the impersonated user and ran the command line at the command prompt. It works fine. So the user does have access to run sign tool in the same way the ASP app is trying to run it. The impersonated user has full access to the Xap package for signing.
Here is the code for running command line calls in our app:
/// <summary> /// Call a command and wait for it exit /// </summary> /// <param name="command"></param> public static void CallExternalProcess(string command, string arguments) { var startInfo = new ProcessStartInfo(); startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; if (arguments == null) { startInfo.FileName = "cmd.exe"; startInfo.Arguments = command; } else { startInfo.FileName = command; startInfo.Arguments = arguments; } var process = Process.Start(startInfo); var stdOut = process.StandardOutput.ReadToEnd(); process.WaitForExit(); if (process.ExitCode > 0) { throw new Exception(string.Format("The command {0} failed with the Exit Code of {1}. Args: {2}. \r\nCommand Output:\r\n{3}", command, process.ExitCode, arguments, stdOut)); } }
What is going wrong? Why is signtool bombing out with an exit code of 1?