Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

Certificate problem calling WCF MSMQ service from ASP.Net application

 
 
Thread Tools Display Modes
Old 07-11-2007   #1 (permalink)
Dave
Guest


 

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.

Old 07-12-2007   #2 (permalink)
Dave
Guest


 

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.

 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Porbs with Certificate for eFax Service for Novis (SONAECOM Portug Wilson Pacheco (PTG) Live Mail 0 12-13-2007 08:55 PM
[MSMQ]Shell for basic opeartions with MSMQ ? Oriane PowerShell 4 09-25-2007 05:11 AM
Vista FTP Service / FTP Application WebOrdy Vista General 2 07-07-2007 08:09 PM
Problem Calling String(char[] value) constructor Keith Hill [MVP] PowerShell 4 07-17-2006 07:17 PM








Vistax64.com 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 2005-2008

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 47 48 49 50