Geeks With Blogs
Paul's Petrov Whiteboard [BizTalk, Enterprise Application Integration, Business Process Automation, SOA, .NET]

Recently, while debugging desktop client - WCF service application I came across this error:

System.ServiceModel.Security.MessageSecurityException was caught
Message=”An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.”
Source=”mscorlib”
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

InnerException: System.ServiceModel.FaultException
Message=”An error occurred when verifying security for the message.”

Client was connecting basic http binding with security mode TransportWithMessageCredential. All other desktop clients were able to successfully call WCF service but not this particular one. Thanks to this post the issue was quickly understood and resolved. Apparently, the client machine was a brand new netbook just out of the box and clock was way off. Interesting thing that Windows automatic clock synchronization did not work.

 

Posted on Tuesday, August 11, 2009 9:59 AM .Net | Back to top


Comments on this post: WCF Message Authentication Failure

# re: WCF Message Authentication Failure
Requesting Gravatar...
Try to disable the synchronizing computer time with an Internet time server, following these steps:

*** If you are a member of a domain, just ignore my tip, 'cos in this case the "Internet Time" tab does not appear for you.

1. Double-click the time on the Windows XP Taskbar to open the "Date and Time Properties" multi-tabbed dialog box;
2. When this dialog box appears, click the "Internet Time" tab;
3. Uncheck "Automatically synchronize with an Internet time server";
4. Don't forget to check/adjust your clock;
5. Click "OK" to close the dialog box;
6. Finally, proceed with your test!

Let me know if this helped you.
All the best,

Fábio Demarchi
Systems Analyst
fabiodemarchi@gmail.com
fabiodemarchi@googlewave.com
Left by Fábio Demarchi on Oct 30, 2009 1:15 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
Yes, it really works. Thanks alot
Left by Dev on Nov 24, 2009 2:21 AM

# re: WCF Message Authentication Failure
Requesting Gravatar...
it works well,but why?
Left by loverwei on Jan 13, 2010 2:36 AM

# re: WCF Message Authentication Failure
Requesting Gravatar...
I would be guessing but, message authentication in WCF by default encrypts the credentials. Encryption usually depends upon some type of salt / seed which can be based upon the current system time. My guess is that the date / time on the client and server is not insignificantly out of step resulting in the encryption / decryption failing.
Left by DavidHalligan on Feb 04, 2010 12:14 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
Thanks, you saved me a ton of time. My servers were off by less than 5 minutes and failed. hen I synced them my app ran fine.
Left by Gregg McGilvray on Mar 09, 2010 2:48 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
Hey Thanks a lot!! it saved my time. I was too facing the same Error. :)
Left by Vishal on Mar 26, 2010 11:43 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
I have the same error and everywhere I look I'm told it's a time synching issue- but I'm running client and server in dev on the same machine! argh!
Left by Cav on May 16, 2010 6:51 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
well its work for me,well done and thanks in advance
Left by mortgage calculator on Jun 08, 2010 11:42 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
thanks for posting i have been looking for this
Left by komputer on Jun 16, 2010 10:49 AM

# re: WCF Message Authentication Failure
Requesting Gravatar...
GRACIAS LOCO! SOS UN GROSO
Left by Ova on Jun 29, 2010 7:19 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
member of domain ..how to resolve..ideas?
Left by Dhivya on Aug 17, 2010 5:29 AM

# re: WCF Message Authentication Failure
Requesting Gravatar...
I hava the same error and I'm using a nettcpbinding... can you help me ??

StackTrace = "\r\nServer stack trace: \r\n at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)\r\n\r\nException rethrown at [0]: \r\n at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\r\n at ...

Left by wcftest on Oct 15, 2010 7:19 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
but in case of wsHttpBinding it is not working
Left by Santosh on Apr 12, 2011 12:49 AM

# re: WCF Message Authentication Failure
Requesting Gravatar...
How I can do if I want to allow connections from clients with more than 5 minutes apart because customers are from different countries?
Left by Jim Miñano on Nov 14, 2011 3:28 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
Increase maxClockSkew value to the desired time interval in the WCF binding configuration
Left by Paul on Nov 14, 2011 3:41 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
Hi everyone, I also got the same error. Client was connecting basic http binding with security mode TransportWithMessageCredential. The only difference is that once I refresh the website or simply add a space into web.config, the first request always succeeds. Then, subsequent calls will fail with the same error. The IIS Failed request trace file shows the error "”An error occurred when verifying security for the message". If I wait to make a same call again after a while say 1 hours. The request will succeed again. I already check with client, their server's time is synced with our service server. Since the pattern I am seeing that each time website is refreshed, the request will succeed. Does everyone know what it might be? How to make the website refresh each time after the call is completed?
Thanks in advance!
Left by Wei on Mar 12, 2012 11:27 AM

# re: WCF Message Authentication Failure
Requesting Gravatar...
Hello Fábio Demarchi,

I just wanna thank you !!, you saved my day !!!!!

thanks alottttttt
Left by Mahmoud tayem on Feb 13, 2013 1:51 AM

# re: WCF Message Authentication Failure
Requesting Gravatar...
Awesome!!!

Thanks!!!
Left by Pieter van Aarde on May 27, 2013 2:22 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
Amazing, adjust the clock correctly solved my problem on mac OS X client. Spent 2 days just to find the culprit. Thanks a lot.
Left by dionsaurus on Jul 23, 2013 4:06 PM

# re: WCF Message Authentication Failure
Requesting Gravatar...
Good article and helping tip. Its saving lot of time and disruptions that are time hunting
-
Left by Zahid Nawaz on Jan 21, 2015 9:26 PM

Your comment:
 (will show your gravatar)


Copyright © Paul Petrov | Powered by: GeeksWithBlogs.net