I've created a simple Subversion command-line wrapper which I intended to use in a ASP.NET application. The wrapper uses System.diagnostics.Process to start cmd.exe and process the SVN commands. When I originally created the library I tested it with a console application; everything worked as expected. When I attempted to use the wrapper in my web app, however, I encountered an issue. After troubleshooting the issue I identified the problem to be caused by the fact that our SVN server uses SSL. When the command is run through the web app the process on the machine is created by the ASPNET user. Because there is no certificate associated with ASPNET user, there following errorr is encountered:
Error validating server certificate for '- The certificate is not issued by a trusted authority. Use the fingerprint to validate the certificate manually!"
If I could manually run the command as the ASPNET user I would then be prompted to accept the certificate and could do so permanently; this would resolve the issue. The problem is that I don't know the password. If I could ensure that cmd.exe was started under a specific user account then I could also resolve my issue... However, I don't know how this would be possible. I tried using runas.exe in my System.Diagnostics.Process, but had no success going that route either. Any suggestions on how I can get arount this issue?
The code used to execute the command looks like this:
The "command" variable is passed in as a parameter. An example value for this parameter is:
/C svn list
Any suggestions would be appreciated.
Thanks,
Kevin Davie
Consultant
Sogeti USA
Error validating server certificate for '- The certificate is not issued by a trusted authority. Use the fingerprint to validate the certificate manually!"
If I could manually run the command as the ASPNET user I would then be prompted to accept the certificate and could do so permanently; this would resolve the issue. The problem is that I don't know the password. If I could ensure that cmd.exe was started under a specific user account then I could also resolve my issue... However, I don't know how this would be possible. I tried using runas.exe in my System.Diagnostics.Process, but had no success going that route either. Any suggestions on how I can get arount this issue?
The code used to execute the command looks like this:
Code:
Process p = new Process();
StreamWriter sw;
StreamReader sr;
StreamReader err;
int ExitCode;
ProcessStartInfo psI = new ProcessStartInfo("cmd.exe", command);
psI.UseShellExecute = false;
psI.RedirectStandardInput = true;
psI.RedirectStandardOutput = true;
psI.RedirectStandardError = true;
psI.CreateNoWindow = true;
p.StartInfo = psI;
p.Start();
sw = p.StandardInput;
sr = p.StandardOutput;
err = p.StandardError;
ProcessReader pr = new ProcessReader(sr);
ProcessReader er = new ProcessReader(err);
pr.Start();
er.Start();
p.WaitForExit();
pr.WaitForExit();
er.WaitForExit();
ExitCode = p.ExitCode;
string[] lines = Regex.Split(pr.Output, @"\r?\n");
/C svn list
Any suggestions would be appreciated.
Thanks,
Kevin Davie
Consultant
Sogeti USA