Problem with HTTPS request from Windows service  
Author Message
interpro1





PostPosted: .NET Framework Networking and Communication, Problem with HTTPS request from Windows service Top

I have built a class library that accesses a couple of web sites using HTTPS. (Visual 2005, Framework 2.0)

When I use it with a console application everything works fine.

But when I use it in a Windows service the HTTPS requests fail with various errors, for example:

The remote server returned an error: (403) Forbidden.

or at best it returns strange HTML content, not at all what I expect...

This seems to be somehow related to the handling of certificates, but as I mentionned above, no problems when the running as a console application!

From the (C#) code perspective there is not difference between the Windows service and console application.

Any suggestion on this problem would be greatly appreciated, I really need to make this work for a costumer.



.NET Development13  
 
 
interpro1





PostPosted: .NET Framework Networking and Communication, Problem with HTTPS request from Windows service Top

Just to try something I added code to accept all certificate (then I got the error above. Otherwise I get this (sorry for the lenghty message) :

(When I run the software (class library) from a console app instead of a service no problems)

ERROR 2006-Nov-23 08:36:34.301 HTTP exception, error reaching URL https://xyz... System.Net.WebResponse GetResponse()

ERROR 2006-Nov-23 08:36:34.301 HTTP exception, error reaching URL https://xyz... System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.TlsStream.CallProcessAuthentication(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)

ERROR 2006-Nov-23 08:36:34.301 HTTP exception, error reaching URL https://xwz... at System.Net.HttpWebRequest.GetResponse()
at PSO.TSR.Robot.Dispatcher.TestUrl(String testURL)

ERROR 2006-Nov-23 08:36:34.286 HTTP exception, error reaching URL https://xyz... The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.


 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, Problem with HTTPS request from Windows service Top

Are you running Windows Service under Local User Account If not please try this and see what happens

Best Regards,

Rizwan