ASP.Net problem with process.start


S

Steve B.

Hi,

I've build a custom web service that is used to digitally signed cab files
that are used to install smart devices application.
Using a standard Process.start and processstartinfo pattern, I run this
command line :

filename :
c:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\signtool.exe

command line arguments :
sign /f "c:\test\mykey.pfx" -p "password" /v "c:\temp\cabfiletosign.cab"


When this process is executed, and even if the files actually exist (I've
check many times), I get the following error (from the standarderror stream
of the process object) :

--------------------------------------------------
Number of files successfully Signed: 0

Number of warnings: 0

Number of errors: 1

SignTool Error: File not found: c:\test\mykey.pfx
--------------------------------------------------

If I run exactly the same code (a class lib that is referenced in the WS)
from a windows desktop application, I get the following behavior :

--------------------------------------------------
The following certificate was selected:
Issued to: Our company
Issued by: the company
Expires: 01/01/2009 01:59:59
SHA1 hash: the hash

Done Adding Additional Store

Attempting to sign: c:\temp\cabfiletosign.cab
Successfully signed: c:\temp\cabfiletosign.cab

Number of files successfully Signed: 1
Number of warnings: 0
Number of errors: 0
--------------------------------------------------

I've set up IIS 6 to make the web service run with a specific user with it's
own app pool. I've also check that the web service's user can access to all
files that are needed..

Does anybody have an idea about this difference ?
Is there any env variable that could cause ASP.Net web apps to work
differently ?

Thanks in advance,
Steve
 
Ad

Advertisements

V

Vadym Stetsyak

Hello, Steve!

ASP.NET and common destop app can have different working directories.

Try to set UserShellExcute to false and see what will happen.

You wrote on Fri, 8 Jun 2007 14:44:25 +0200:

SB> Hi,

SB> I've build a custom web service that is used to digitally signed cab
SB> files
SB> that are used to install smart devices application.
SB> Using a standard Process.start and processstartinfo pattern, I run
SB> this
SB> command line :

SB> filename :
SB> c:\Program Files (x86)\Microsoft Visual Studio
SB> 8\Common7\Tools\Bin\signtool.exe

SB> command line arguments :
SB> sign /f "c:\test\mykey.pfx" -p "password" /v
SB> "c:\temp\cabfiletosign.cab"


SB> When this process is executed, and even if the files actually exist
SB> (I've
SB> check many times), I get the following error (from the standarderror
SB> stream
SB> of the process object) :

SB> --------------------------------------------------
SB> Number of files successfully Signed: 0

SB> Number of warnings: 0

SB> Number of errors: 1

SB> SignTool Error: File not found: c:\test\mykey.pfx
SB> --------------------------------------------------

SB> If I run exactly the same code (a class lib that is referenced in
SB> the WS)
SB> from a windows desktop application, I get the following behavior :

SB> --------------------------------------------------
SB> The following certificate was selected:
SB> Issued to: Our company
SB> Issued by: the company
SB> Expires: 01/01/2009 01:59:59
SB> SHA1 hash: the hash

SB> Done Adding Additional Store

SB> Attempting to sign: c:\temp\cabfiletosign.cab
SB> Successfully signed: c:\temp\cabfiletosign.cab

SB> Number of files successfully Signed: 1
SB> Number of warnings: 0
SB> Number of errors: 0
SB> --------------------------------------------------

SB> I've set up IIS 6 to make the web service run with a specific user
SB> with it's
SB> own app pool. I've also check that the web service's user can access
SB> to all
SB> files that are needed..

SB> Does anybody have an idea about this difference ?
SB> Is there any env variable that could cause ASP.Net web apps to work
SB> differently ?

SB> Thanks in advance,
SB> Steve



With best regards, Vadym Stetsyak.
Blog: http://vadmyst.blogspot.com
 
S

Steve B.

Since I'm using full path and not relative path, I don't think this could be
a working directory problem.

Here is the process.start wrapper I wrote to launch the signtool.exe process
:

---------------------------------------------------------------------------
public static string StartProcessAndGetOutput(
string fileName,
bool runInFileNameDirectory,
string arguments
)
{
string log;
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = fileName;
psi.Arguments = arguments;
if (runInFileNameDirectory) psi.WorkingDirectory =
Path.GetDirectoryName(fileName);
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
StringBuilder sbLog = new StringBuilder();
using (Process p = Process.Start(psi))
{
string output = string.Empty;
while ((output = p.StandardOutput.ReadLine()) != null)
{
sbLog.AppendLine(output);
}
sbLog.Append(p.StandardOutput.ReadToEnd());
sbLog.Append(p.StandardError.ReadToEnd());
p.WaitForExit();
}
log = sbLog.ToString();
return log;
}
---------------------------------------------------------------------------
As you can see, I disable UseShellExecute, and I also added a parameter that
allow me to specify if the working directory is the filename directory.

You can also notice that the error message returns the full path of the
targeted file... which is correct.

Thanks,
Steve
 
M

Mehdi

As you can see, I disable UseShellExecute, and I also added a parameter that
allow me to specify if the working directory is the filename directory.

You can also notice that the error message returns the full path of the
targeted file... which is correct.

I'm sure that you've already checked that but are you sure that the file
you are trying to sign is really placed on the machine on which the Web
Service runs (the web server) and not on the machine on which you are
accessing it the web service.
 
H

Henning Krause [MVP - Exchange]

Hello Steve,

the program may need access to a temporary files folder. I'd suggest you get
FileMon from Microsoft (formerly Sysinternals) and check for Access denied
messages.

Best regards,
Henning Krause
 
Ad

Advertisements

S

Steve B.

Thanks all for your feedbacks but I finnally "unblocked" the situation...

I reset the password of the user that runs the app pool (to the same
password !!!, app pools worked and continued to work), and at this point,
the web service started to work properly.

I can't find any explanation of this "magic" behaviour... but it's working
now.

Thanks for all people that tried to help me !

Steve
 
Ad

Advertisements

S

Steve B.

Hum... the problem is still present (hope failed)...

I don't know if it can help, but here is the PATH variable :

-------------------------------------------------------------
E:\WINDOWS\system32
E:\WINDOWS
E:\WINDOWS\System32\Wbem
E:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\
E:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\
E:\Program Files\Microsoft SQL Server\90\DTS\Binn\
E:\Program Files\Microsoft SQL Server\90\Tools\binn\
E:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\
E:\Program Files (x86)\Microsoft SQL
Server\90\Tools\Binn\VSShell\Common7\IDE\
E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\IDE\PrivateAssemblies\
E:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\
E:\Program Files (x86)\Common Files\Roxio Shared\9.0\DLLShared\
E:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin\
-------------------------------------------------------------

And the filemon result (only failures) :
-------------------------------------------------------------
E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\signtool.exe.Manifest
NOT FOUND
Options: Open Access: 001200A9

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\signtool.exe.Local
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\wow64log.dll
NOT FOUND
Attributes: Error

E:\WINDOWS\system32\wow64log.dll
NOT FOUND
Attributes: Error

E:\WINDOWS\system\wow64log.dll
NOT FOUND
Attributes: Error

E:\WINDOWS\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\wow64log.dll
NOT FOUND
Attributes: Error

E:\WINDOWS\system32\wow64log.dll
NOT FOUND
Attributes: Error

E:\WINDOWS\wow64log.dll
NOT FOUND
Attributes: Error

E:\WINDOWS\System32\Wbem\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files\Microsoft SQL Server\90\DTS\Binn\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files\Microsoft SQL Server\90\Tools\binn\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft SQL
Server\90\Tools\Binn\VSShell\Common7\IDE\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\IDE\PrivateAssemblies\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Common Files\Roxio Shared\9.0\DLLShared\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\12\bin\wow64log.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\signtool.exe.Local
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\signtool.exe
ACCESS DENIED
computer\apppool_user

E:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Tools\Bin\MFC42.DLL
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\WSOCK32.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\WS2_32.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\WS2HELP.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\ODBC32.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\signtool.exe.Local\
NOT FOUND
Attributes: Error

E:\WINDOWS\syswow64\CRYPTUI.dll.2.Config
NOT FOUND
Options: Open Access: 001200A9

E:\WINDOWS\syswow64\WININET.dll.123.Config
NOT FOUND
Options: Open Access: 001200A9

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\signtool.exe.Local\
NOT FOUND
Attributes: Error

E:\WINDOWS\WindowsShell.Config
NOT FOUND
Options: Open Access: 001200A9

E:\WINDOWS\syswow64\SHELL32.dll.124.Config
NOT FOUND
Options: Open Access: 001200A9

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\signtool.exe.Local\
NOT FOUND
Attributes: Error

E:\WINDOWS\SysWOW64\MFC42LOC.DLL
NOT FOUND
Attributes: Error

E:\WINDOWS\SysWOW64\MFC42LOC.DLL
NOT FOUND
Attributes: Error

E:\WINDOWS\SysWOW64\MFC42LOC.DLL.DLL
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\signtool.exe.Local\
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\RichEd20.dll
NOT FOUND
Attributes: Error

E:\WINDOWS\SysWOW64\rpcss.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\uxtheme.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\CLBCatQ.DLL
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\COMRes.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft CAPICOM 2.1.0.2\Lib\X86\MSSIGN32.dll
NOT FOUNDAttributes: Error

E:\WINDOWS\SysWOW64\MSSIGN32.dll.2.Config
NOT FOUND
Options: Open Access: 001200A9

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\rsaenh.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\rsaenh.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\rsaenh.dll
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Tools\Bin\PSAPI.DLL
NOT FOUND
Attributes: Error

E:\Program Files (x86)\Microsoft Visual Studio
8\Common7\Tools\Bin\USERENV.dll
NOT FOUND
Attributes: Error

E:\WINDOWS\debug\UserMode\ChkAcc.log
ACCESS DENIED
computer\apppool_user

E:\WINDOWS\debug\UserMode\ChkAcc.log
ACCESS DENIED
computer\apppool_user

-------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top