Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF Error - Message security verification failed
    primarykey
    data
    text
    <p>I'm trying to get going with a new WCF service. The service was working before layering on security. Now I am getting this error:</p> <pre><code>An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. 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.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&amp; msgData, Int32 type) at MyProject.IntegrationSample.MyProjectService.IMyProjectService.GetData(Int32 value) at MyProject.IntegrationSample.MyProjectService.MyProjectServiceClient.GetData(Int32 value) in C:\code\AdvancedFraudSolutions\MyProject4.0\MyProject.IntegrationSample\Service References\MyProjectService\Reference.cs:line 82 at MyProject.IntegrationSample.Program.Main(String[] args) in C:\code\AdvancedFraudSolutions\MyProject4.0\MyProject.IntegrationSample\Program.cs:line 22 At least one security token in the message could not be validated. </code></pre> <p>And this in the trace log:</p> <pre><code>Message security verification failed. </code></pre> <p>Here is my service configuration:</p> <pre><code>&lt;system.serviceModel&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;binding name="basicBinding"&gt; &lt;security mode="TransportWithMessageCredential"/&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;/bindings&gt; &lt;services&gt; &lt;service name="MyProject.IntegrationServices.MyProjectService" behaviorConfiguration="basicServiceBehavior"&gt; &lt;endpoint binding="basicHttpBinding" bindingConfiguration="basicBinding" name="MyProjectServiceEndpoint" contract="MyProject.IntegrationServices.IMyProjectService" /&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="basicServiceBehavior"&gt; &lt;serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt; &lt;serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="AspNetSqlRoleProvider" /&gt; &lt;serviceCredentials&gt; &lt;serviceCertificate findValue="MyServiceCert" x509FindType="FindBySubjectName" /&gt; &lt;userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider" /&gt; &lt;/serviceCredentials&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt; &lt;diagnostics&gt; &lt;messageLogging maxMessagesToLog="25000" logEntireMessage="true" logMessagesAtServiceLevel="false" logMalformedMessages="true" logMessagesAtTransportLevel="true"&gt; &lt;filters&gt; &lt;clear/&gt; &lt;/filters&gt; &lt;/messageLogging&gt; &lt;/diagnostics&gt; &lt;/system.serviceModel&gt; </code></pre> <p>Here is my test client code and configuration:</p> <pre><code> static void Main(string[] args) { MyProjectServiceClient client = new MyProjectServiceClient(); client.ClientCredentials.UserName.UserName = "theuser"; client.ClientCredentials.UserName.Password = "thepass"; try { string result = client.GetData(100); client.Close(); Console.WriteLine(result); } catch (Exception ex) { client.Abort(); PrintExceptionDetail(ex); } Console.ReadLine(); } private static void PrintExceptionDetail(Exception ex) { StringBuilder detail = new StringBuilder(); while (ex != null) { detail.AppendLine(ex.Message); detail.AppendLine(ex.StackTrace); ex = ex.InnerException; } Console.WriteLine(detail); Console.Write("Copy exception detail to clipboard? (y/n) "); if (Console.ReadLine().ToLower() == "y") { Clipboard.SetText(detail.ToString()); } } &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;binding name="MyProjectServiceEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/&gt; &lt;security mode="TransportWithMessageCredential"&gt; &lt;transport clientCredentialType="None" proxyCredentialType="None" realm=""/&gt; &lt;message clientCredentialType="UserName" algorithmSuite="Default"/&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint address="https://localhost:44306/MyProjectService.svc" binding="basicHttpBinding" bindingConfiguration="MyProjectServiceEndpoint" contract="MyProjectService.IMyProjectService" name="MyProjectServiceEndpoint"/&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; </code></pre> <p>You can see that I'm trying to use basicHttpBinding, TransportWithMessageCredential security, and Membership/Role providers for authentication/authorization.</p> <p>This is being developed using IIS express and will be hosted in IIS.</p> <p>What is the cause of the errors?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload