Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Certificate problem calling WCF MSMQ service from ASP.Net application

 
 
Old 07-12-2007   #1 (permalink)
Dave


 
 

Certificate problem calling WCF MSMQ service from ASP.Net application

I have an ASP.Net application that calls a WCF MSMQ service. The
service is hosted in a Windows Service (Windows 2003 Standard) and is
working correctly.

The MSMQ queue only accepts authenticated messages, i.e. each message
must be signed with a certificate.

The service is called from an ASP.Net application that runs in an
application pool with a least privilege user identity. When the web
application calls the web service I get a server error saying the X.
509 certificate could not be found. If I then open a command prompt
"runas" the least privilege user identity, the call to the web service
succeeds.

I am assuming this is to do with the profile for the identity. Asp.Net
performs a network login for the user which doesn't load the user's
profile (that contains the users certificate store). By opening a
command prompt "runas" the user, the profile is loaded and the
certificate can be located.

Please tell me there is a simple way to fix this issue. I have tried a
variety of fixes all to no avail. I have put the certificate in the
machine store which allows the client to locate the certificate but
then MSMQ fails with an MQ_ERROR_INVALID_CERTIFICATE. Again, this goes
away if I put the certificate into the identity's certificate store as
well as in the machine store and also open the command prompt "runas"
the identity.


My System SpecsSystem Spec
Old 07-12-2007   #2 (permalink)
Dave


 
 

Re: Certificate problem calling WCF MSMQ service from ASP.Net application

On Jul 12, 4:57 pm, Dave <pigwi...@gmail.com> wrote:
> I have an ASP.Net application that calls a WCF MSMQ service. The
> service is hosted in a Windows Service (Windows 2003 Standard) and is
> working correctly.
>
> The MSMQ queue only accepts authenticated messages, i.e. each message
> must be signed with a certificate.
>
> The service is called from an ASP.Net application that runs in an
> application pool with a least privilege user identity. When the web
> application calls the web service I get a server error saying the X.
> 509 certificate could not be found. If I then open a command prompt
> "runas" the least privilege user identity, the call to the web service
> succeeds.
>
> I am assuming this is to do with the profile for the identity. Asp.Net
> performs a network login for the user which doesn't load the user's
> profile (that contains the users certificate store). By opening a
> command prompt "runas" the user, the profile is loaded and the
> certificate can be located.
>
> Please tell me there is a simple way to fix this issue. I have tried a
> variety of fixes all to no avail. I have put the certificate in the
> machine store which allows the client to locate the certificate but
> then MSMQ fails with an MQ_ERROR_INVALID_CERTIFICATE. Again, this goes
> away if I put the certificate into the identity's certificate store as
> well as in the machine store and also open the command prompt "runas"
> the identity.


Ok so assuming it's a profile issue, why don't I just try to load the
profile for the least priv user identity (fingers crossed re
formatting):

PROFILEINFO profileInfo = new PROFILEINFO();
profileInfo.lpUserName = WindowsIdentity.GetCurrent().Name;
profileInfo.dwSize = Marshal.SizeOf( typeof( PROFILEINFO));

if (!OpenProcessToken( GetCurrentProcess(),
TOKEN_QUERY |
TOKEN_IMPERSONATE | TOKEN_DUPLICATE,
out m_hProcessToken))
{
int lastError = Marshal.GetLastWin32Error();
LogEvent.Info(string.Format("GetCurrentProcess failed,
Win32Error:{0}", lastError));
}
else if (!LoadUserProfile( m_hProcessToken, ref profileInfo))
{
int lastError = Marshal.GetLastWin32Error();
LogEvent.Info(string.Format("LoadUserProfile failed,
Win32Error:{0}", lastError));
}

Yay, it works, no wait, LoadUserProfile requires " the caller must be
an administrator", curses.

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Sending a digital certificate in a web service call? VB Script
try to update a Microsoft Visual Studio 2005 ClickOnce application after the certificate that you used to sign the installation expires, error message recieved .NET General
Porbs with Certificate for eFax Service for Novis (SONAECOM Portug Live Mail
[MSMQ]Shell for basic opeartions with MSMQ ? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46