【问题标题】:WCF Security processor was unable to find a security header in the messageWCF 安全处理器无法在消息中找到安全标头
【发布时间】:2011-09-06 09:45:40
【问题描述】:

首先,我是 WCF 新手,所以很可能我正在做一些非常琐碎非常错误的事情。无论如何,我目前正在开发 WCF 服务,该服务使用 wsHttpBinding 进行通信,以及 clientCredentialType 用户名。

WCF 规定使用凭证来加密通信(我已将其设置为“快速而肮脏”,因为我还没有生产证书。)。

当我直接从 Visual Studio 开发或测试服务时,地址变为http://localhost:123223/Checks.svc 一切正常,但是如果我将确切的项目部署到我的开发机器上的网站我会出现以下异常:

从对方收到不安全或不正确安全的故障 派对。故障代码和细节见内部FaultException。

使用以下堆栈跟踪:

服务器堆栈跟踪:在 System.ServiceModel.Channels.SecurityChannelFactory1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout) at System.ServiceModel.Channels.SecurityChannelFactory1.SecurityRequestChannel.Request(消息 消息,TimeSpan 超时)在 System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation 操作、EndpointAddress 目标、Uri via、SecurityToken currentToken,TimeSpan 超时)在 System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(时间跨度 超时)在 System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(时间跨度 超时)在 System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan 超时)在 System.ServiceModel.Channels.CommunicationObject.Open(时间跨度 超时)在 System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan 超时)
在 System.ServiceModel.Channels.CommunicationObject.Open(时间跨度 超时)在 System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel 通道,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(时间跨度 超时,CallOnceManager 级联)在 System.ServiceModel.Channels.ServiceChannel.EnsureOpened(时间跨度 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串 action, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, Object[] 出局,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime 操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 留言)

在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(消息数据& msgData,Int32 类型)在 TestCreditExchangeWCFServices.CreditExchange.WCF.Services.IChecks.CreditCheck(CreditCheck 信用检查1) 在 TestCreditExchangeWCFServices.CreditExchange.WCF.Services.ChecksClient.CreditCheck(CreditCheck 信用检查1) 在 D:\Projects\Temp\TestCreditExchangeWCFServices\TestCreditExchangeWCFServices\Service References\CreditExchange.WCF.Services\Reference.cs:第 1793 行,位于 TestCreditExchangeWCFServices.MainWindow.btnLite_Click(对象发送者, RoutedEventArgs e) 在 D:\Projects\Temp\TestCreditExchangeWCFServices\TestCreditExchangeWCFServices\MainWindow.xaml.cs:line 39

服务器配置:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="HttpBinding">
          <security mode="Message">
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="CreditExchange.WCF.Services.Checks">
        <endpoint address="" binding="wsHttpBinding"
          bindingConfiguration="HttpBinding" contract="CreditExchange.WCF.Services.IChecks">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding"  contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <!--<serviceDebug includeExceptionDetailInFaults="true" />-->
          <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="NHibernateRoleProvider" />
          <serviceCredentials>
            <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName"
                              storeLocation="LocalMachine" storeName="My" />
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
              membershipProviderName="CredentialsProvider" />
          </serviceCredentials>
          <errorHandler />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <extensions>
      <behaviorExtensions>
        <add name="errorHandler"
              type="Common.Library.WCF.Exceptions.UnhandledExceptionHandlerExtension, Common.Library" />
      </behaviorExtensions>
    </extensions>
  </system.serviceModel>

客户端配置:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IChecks" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
            allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" negotiateServiceCredential="true"
                algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <!--<endpoint address="http://localhost:52744/Checks.svc" behaviorConfiguration="ClientBehavior" binding="wsHttpBinding"
          bindingConfiguration="WSHttpBinding_IChecks" contract="CreditExchange.WCF.Services.IChecks"
          name="WSHttpBinding_IChecks">-->
      <endpoint address="http://localhost/CreditExchange.WCF.Services/Checks.svc" behaviorConfiguration="ClientBehavior" binding="wsHttpBinding"
        bindingConfiguration="WSHttpBinding_IChecks" contract="CreditExchange.WCF.Services.IChecks"
        name="WSHttpBinding_IChecks">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
    <behaviors>
      <!-- Needed because otherwise we get errors because the Cert chain can not be verified -->
      <endpointBehaviors>
        <behavior name="ClientBehavior">
          <clientCredentials>
            <serviceCertificate>
              <authentication certificateValidationMode="None" />
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

我已经用谷歌搜索过,我看到提到导致这个问题的时间戳问题,但我根本不明白在完全相同的机器上运行在 VS 调试环境中的东西如何运行良好,但发布时会抛出一个错误,我无法绕开我的头。

我在显示以下异常的客户端上启用了跟踪(这对我来说没有意义):

Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties.   This can occur if the service is configured for security and the client is not using security.

我跟踪了两条消息,一条成功(在我的调试版本上)和一条失败,我正在查看差异,我唯一能看到的是 Via 标签(一个针对我的 FQDN 出于某种原因, 而不是 localhost) 并且 AppDomain 不同(这是有道理的)

成功:

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>262163</EventID>
<Type>3</Type>
<SubType Name="Information">0</SubType>
<Level>8</Level>
<TimeCreated SystemTime="2011-09-06T10:04:03.6960710Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{1a2bd6e0-c785-468b-95ea-d8b464abec94}" />
<Execution ProcessName="WebDev.WebServer40" ProcessID="2792" ThreadID="31" />
<Channel />
<Computer>PC-FOLKERT</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information">
<TraceIdentifier>http://msdn.microsoft.com/nl-NL/library/System.ServiceModel.Channels.MessageReceived.aspx</TraceIdentifier>
<Description>Received a message over a channel.</Description>
<AppDomain>f67db61a-2-129597770339060921</AppDomain>
<Source>System.ServiceModel.Activation.HostedHttpContext+HostedHttpInput/64865147</Source>
<ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/MessageTransmitTraceRecord">
<MessageProperties>
<Encoder>application/soap+xml; charset=utf-8</Encoder>
<AllowOutputBatching>False</AllowOutputBatching>
<Via>http://localhost:52744/Checks.svc</Via>
</MessageProperties>
<MessageHeaders>
<a:Action s:mustUnderstand="1" u:Id="_4" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</a:Action>
<a:MessageID u:Id="_5" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:a="http://www.w3.org/2005/08/addressing">urn:uuid:7117ff27-a64b-4b86-9f80-127225fd3e44</a:MessageID>
<ActivityId CorrelationId="4878f073-6eed-4f48-a8a1-bc792112cfd8" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-000000000000</ActivityId>
<a:ReplyTo u:Id="_6" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:a="http://www.w3.org/2005/08/addressing">
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1" u:Id="_7" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">http://localhost:52744/Checks.svc</a:To>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<u:Timestamp u:Id="uuid-54189139-4404-4f93-a197-4438ab5f3fde-5" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<u:Created>2011-09-06T10:04:03.580Z</u:Created>
<u:Expires>2011-09-06T10:09:03.580Z</u:Expires>
</u:Timestamp>
<c:SecurityContextToken u:Id="uuid-c4807903-c4a0-4ef0-9712-bd05f8788780-1" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<c:Identifier>urn:uuid:e3f5c663-9b49-45b6-8774-5292da16ca2e</c:Identifier>
</c:SecurityContextToken>
<c:DerivedKeyToken u:Id="_0" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" URI="#uuid-c4807903-c4a0-4ef0-9712-bd05f8788780-1"></o:Reference>
</o:SecurityTokenReference>
<c:Offset>0</c:Offset>
<c:Length>24</c:Length>
<c:Nonce>
<!-- Removed-->
</c:Nonce>
</c:DerivedKeyToken>
<c:DerivedKeyToken u:Id="_1" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" URI="#uuid-c4807903-c4a0-4ef0-9712-bd05f8788780-1"></o:Reference>
</o:SecurityTokenReference>
<c:Nonce>
<!-- Removed-->
</c:Nonce>
</c:DerivedKeyToken>
<e:ReferenceList xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:DataReference URI="#_3"></e:DataReference>
<e:DataReference URI="#_8"></e:DataReference>
<e:DataReference URI="#_9"></e:DataReference>
</e:ReferenceList>
<e:EncryptedData Id="_9" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"></e:EncryptionMethod>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/dk" URI="#_1"></o:Reference>
</o:SecurityTokenReference>
</KeyInfo>
<e:CipherData>
<e:CipherValue>T9HGceq5Weq5n5Cygk/YzOb9JRFrJVGLdgB+Bf2cDcwue6/Wf5HUg0Krl35/e05wtuwTwNNCH4Q9a8e8+J9+L68tYVijYKwlxJZBIEHLx2XCCKqbve6DWc3VYmaX8mNqDXtKC8cfAtW1O5oH8m/6lCnuN+sZoQDgYh97S5f7AusJdT+eTb9OFarhH5HwiupUjERpnYWAXWoSUgjjCKxIp0iD+MpRGCGA2/7xt+WvfDgX2B/c1DvzuWwx+Kwv7HiXeHS6ZVfnTTYZO3e4GTq7TDYtMThLvw3hGOkK5nb/IDOlGLqWEBk4tzdKgIn7FGssOdhohXyYIAj7x3wzyEirg+HRLg7OO/rtrG0jw/jLdIzs627Hypdbrm9mckAdtxFbh/5p3/CYmGuTr/2ck4EW/a5AM8nkn6J1QT4Cp14Ckr4ZjbvivMKAwGtTcmaJQm6h053b6KOW2lGxO3z+kOjYrE94K993hLvjFfK99LRM1yyApCQyRNMEaKJWNaONmpfdSEAcfrpx+bp0+Fohm1D+8AyYL0m4+tSign7btWZFwU5y8P7ggVQuGrJ0ew0EpDscurFL9FOfZf4H6+qidH305o4CkY0BZanwb6kDhLzxA/0=</e:CipherValue>
</e:CipherData>
</e:EncryptedData>
<e:EncryptedData Id="_8" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"></e:EncryptionMethod>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/dk" URI="#_1"></o:Reference>
</o:SecurityTokenReference>
</KeyInfo>
<e:CipherData>
<e:CipherValue>Nni+QmkTzz7sQ56j3vkzS9v19wYLTCtqQrAMOk07fzCCYG31rUfGKzH9bBF8Fmjc/cdmeNRa7YonvNRusaDzPaZgyzWQharZh6uf4EqgwizId8Xk67e1SIVHqSfb8KXtijivi0z94B+cp21wRNomV4h4EEFNJvTlLzNen3GKXwz87cDYUdDhNTEvQOFLU8a1gd2L06WoQ3IaUngpRI3ffg5WKPKZ5b2O+zIK+jy0ol0MqkyO2c43XzwQLBpJEY489pmUazdSERd6nmndV7FtZfE87ECCApcaNxfAxCHwCndkhQBK6bVA+imO67lA1nuXNL41P3meUH78HX7vSw6ujXxKOoJoqd339G5CDXqvXxGz/UkoOCLWl5j17RqxTApC8f9oMavXTFGqgHjeIsPycmv58yJB10il9mx+j7wNUaj10llExNUU++Y1uVhDwHZ2LQ2bAPXmsZPZ4EDTWz5XFifH2POtN7OmUUrsDpyXyvn/DdAhfn+q4GK9fJuEcc/Co3VQ7rlSib1if8XKjlo8fqrAlh5uFRZirlIrXvVXVt2FVP/bAmfFxKrYTxvpkCJE7EEwjeT4h6PE8GJL0Vujme4ipDuEWzjuZ7y00G29qUbUX2ErN84xLUQPg41oq1LgxKeF3RCOvVer+QtekDWjxPb1rzfN9JJoOHXmx4UOWzmpuYJr8Y6sWUE3aYZEcNBfYvOZ/MSMciv+5nVdP0i9q++2ej3Pu4iSgSadfYX5JsVaZBVx3YWFa/O1C23Zzpp39KJ39ag2vjghX+ywrU5bqoR6OsbpAE2jLD4rq3gvxT25hvDz12UEpjshcXJavToKH2eEMlZ8/xl2OoPe05374AA+3NqwyyWndo4RS3k3ahSFQbBYC8OqQUAIEdMgwxbxzCho6wcifGPKfldOhxiXEkuMUNSTJdEpES7NLRwoWP1h8Qmdrq2BNWrJOcOMqV2u8gS6UBN16uMSCevW/x1IwvA4opWrX9xFTA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>
</e:CipherData>
</e:EncryptedData>
</o:Security>
</MessageHeaders>
</ExtendedData>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>

失败:

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>262163</EventID>
<Type>3</Type>
<SubType Name="Information">0</SubType>
<Level>8</Level>
<TimeCreated SystemTime="2011-09-06T10:38:36.3276859Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{fba8e1c9-a9f9-491e-814a-e1b513188bcc}" />
<Execution ProcessName="w3wp" ProcessID="1896" ThreadID="13" />
<Channel />
<Computer>PC-FOLKERT</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information">
<TraceIdentifier>http://msdn.microsoft.com/nl-NL/library/System.ServiceModel.Channels.MessageReceived.aspx</TraceIdentifier>
<Description>Received a message over a channel.</Description>
<AppDomain>/LM/W3SVC/1/ROOT/CreditExchange.WCF.Services-3-129597790759646859</AppDomain>
<Source>System.ServiceModel.Activation.HostedHttpContext+HostedHttpInput/3683710</Source>
<ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/MessageTransmitTraceRecord">
<MessageProperties>
<Encoder>application/soap+xml; charset=utf-8</Encoder>
<AllowOutputBatching>False</AllowOutputBatching>
<Via>http://pc-folkert.domain.local/CreditExchange.WCF.Services/Checks.svc</Via>
</MessageProperties>
<MessageHeaders>
<a:Action s:mustUnderstand="1" u:Id="_4" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT</a:Action>
<a:MessageID u:Id="_5" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:a="http://www.w3.org/2005/08/addressing">urn:uuid:3352b0d1-a569-4d59-a377-82730c5d07f2</a:MessageID>
<ActivityId CorrelationId="dfd3e02f-53ef-4b33-a5a4-43bb5bf71245" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-000000000000</ActivityId>
<a:ReplyTo u:Id="_6" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:a="http://www.w3.org/2005/08/addressing">
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1" u:Id="_7" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">http://localhost/CreditExchange.WCF.Services/Checks.svc</a:To>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<u:Timestamp u:Id="uuid-6f05a6c6-cffa-492e-ae65-4e02b33a0ef1-5" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<u:Created>2011-09-06T10:38:36.249Z</u:Created>
<u:Expires>2011-09-06T10:43:36.249Z</u:Expires>
</u:Timestamp>
<c:SecurityContextToken u:Id="uuid-63efd986-fc21-47db-84eb-735045c57539-2" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<c:Identifier>urn:uuid:67a5014b-b3e0-4f91-a730-60a2a36d3cbe</c:Identifier>
</c:SecurityContextToken>
<c:DerivedKeyToken u:Id="_0" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" URI="#uuid-63efd986-fc21-47db-84eb-735045c57539-2"></o:Reference>
</o:SecurityTokenReference>
<c:Offset>0</c:Offset>
<c:Length>24</c:Length>
<c:Nonce>
<!-- Removed-->
</c:Nonce>
</c:DerivedKeyToken>
<c:DerivedKeyToken u:Id="_1" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" URI="#uuid-63efd986-fc21-47db-84eb-735045c57539-2"></o:Reference>
</o:SecurityTokenReference>
<c:Nonce>
<!-- Removed-->
</c:Nonce>
</c:DerivedKeyToken>
<e:ReferenceList xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:DataReference URI="#_3"></e:DataReference>
<e:DataReference URI="#_8"></e:DataReference>
<e:DataReference URI="#_9"></e:DataReference>
</e:ReferenceList>
<e:EncryptedData Id="_9" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"></e:EncryptionMethod>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/dk" URI="#_1"></o:Reference>
</o:SecurityTokenReference>
</KeyInfo>
<e:CipherData>
<e:CipherValue>HS9eENPLD7iILYw/0a8IVNQZ/Q30RxnLDPUTTSW1C33ZYnyLG6+c6mzT5T4eooh9Fn5YatOacyM/y33rHkf3S+kmbQ5PMTQ7KIQZQMO/6YfQ4hQI+a5WrTmPIHuYLaSDHB6M4lVOyzJbP4JDSrg8hVTWPBHOo1pQ8MP5MbsScvhYk+UofBqMo2WdyZL3JIxiAXvnbkcab3dnKl2AFqpBnImCAORb2zFP5rNB78epggMa03Uj2vYxJZbLVaDFh/kTuc7Ud9tx5xtLSoyJiBU4AlwqNbI4gKR8+BvbEPnVc9NKTQa98mi10Goyb/oxGPJadVLHS3L8zuH4TH/v0T0gxI8JGR+Ng7JMHADlLGh2W31S8k0UznwrJ2l0DFC86LUMno1k7/EJrXNJuu/GuJjPaspjTM0O1nEvAKmvHAgyt0JAD2NV0W7GnU4/G8JkH5/P8YYHEBy0lsDo+6ejoZ5upYChI5Y1ZsGHa0eLNvP7jYMKTFraF1LLe3quMFQXG7rOWovaXvUleHbzfEqR90GBTATzwpr2WaXJYgiZ8CWu3KJYcR/G6O8EFPsDveVYUHJ+yI2IbecH6uHnABbNWDua5VYJC4jPdJtuEHjA/+iwjKI=</e:CipherValue>
</e:CipherData>
</e:EncryptedData>
<e:EncryptedData Id="_8" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"></e:EncryptionMethod>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<o:SecurityTokenReference>
<o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/dk" URI="#_1"></o:Reference>
</o:SecurityTokenReference>
</KeyInfo>
<e:CipherData>
<e:CipherValue>WT8Qk0NYcBfVQPDfAdpdTXGdDKI3WtnfpkbeBxmFLVeyUsbvi3VCF95bLO2gx+vm+2VukWEWcJ5XA3zuVqyRQP3fNq4PK5sA8MMnqKtm762Z7SB0MjbS1bp5yaJEA+h/3cUwpIqnms2Unf5AbfMBQmp9mrHpcA/FqCs6gV2phu4AzSgzkDbmm9vtNllq+XjDDDQ7AO7BxOzfeH0Wjb5E4TBykaZ4G/RXpxQqxRRZR3uUtYKw+Nr85fe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EnUs2G4lursvNWJj+XasydZKxKJ2ddmcVN+Qyys3tOiOoMsguFl/e/8fsFJ2+RC+ycDDNvQ9vZvLSANq1ITwaIGrgr0dQaduY+dREmQqZ+IrAn4eERMTdbnHSXCFwiVjAdqqbLXvaoDnZFsOG1ImyPHy4DfNwD35GObupKCR9ZSoz65MvRzKfK8FGCoC68s0PCbJ3SfP5TpKcGnslqTwXowLXTmbj2FvsPyNNZ6WIRWtbyC7ZDpaU6Z3rRkEFC9Tl+NUlJ1lDvPCKrk+oB4lH3YuI3pNaquXMKnQWHWDajrmOLD8OIvCSLXpNJjsmddhjAzljcbujDuqsO6eK+WO/jH113HYmQjeVlR3HsGNYBUL6YyqFjGnKTCxDDPvhZfCL0LlfhseQRoihi7J0gc3TyaSYoTdX1vT1q10sj4NUX/1OtxH53sQEDzXsSot8bZTdEcXb4zqGq7iX2TDUkUlN4I1L+3DYqs1FULw+++iA0xe6Vx/myhc13aaPCBNwmsli2ZqVKnl6r4ZSLeczHcmwYNjg1roEQU+oMg84es86GoF454tEyBsJiICf9OaRwCqJZgVi/2LncZSlWM/lJ8K8NAD07rMiqZMASpRjP9XABzG1O4Js1GAa4JBVWg7zTJ2qmBzLAG2AS+0h2TJe1TqjVfSffAT5a/XkVjchk9eMVPkGvnPqgDu9ntYteG81poWS65rPB+K4Y3GK</e:CipherValue>
</e:CipherData>
</e:EncryptedData>
</o:Security>
</MessageHeaders>
</ExtendedData>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>

【问题讨论】:

  • 在服务器上启用跟踪。服务器端很可能有异常。
  • 好吧,如果我添加完全相同的代码来启用服务器上的跟踪,甚至不会创建任何跟踪文件......这让我想知道是否有任何东西到达服务器。好的,我通过发布添加了跟踪(认为 web.config 没有刷新或其他什么......)现在它跟踪了,现在梳理一下。
  • 我在服务器跟踪中看到的唯一内容是警告(不是例外)我会将跟踪编辑到问题中。
  • 它说它无法验证传入的消息
  • 是的,但是为什么在通过 IIS 发布时验证它会出现问题?但是当我在调试中运行它时没有这个问题?另外,它的哪个部分有问题?时间戳?证书(我讨厌证书,它们毁了我的生活>.

标签: c# wcf security .net-4.0 certificate


【解决方案1】:

所以……嗯……我觉得很惭愧……

基本上在请求失败后,我会打开跟踪日志并收到文件未正确关闭的消息。由于某种原因,该服务不会像我预期的那样快速写入它。直到午餐后我才注意到这一点(我想这有助于退后一步)。我在“未正确关闭”消息上向右滚动,发现它显示异常。

这触发了我,因为到目前为止我只在日志中看到了警告。因此,我在 Notepad++ 中打开了该文件,并阅读了一段时间以来我见过的最愚蠢的异常。它缺少一个程序集...(确切地说是 NHibernate 程序集之一)。

可悲的是,当我从 VS2010 发布时,它没有发布这些程序集,为什么完全超出了我的范围……我只是浪费了两个多小时的生命,因为它没有发布它确实放在调试箱中的文件... 再加上我没有正确查看这些日志文件真的让我很不开心。

顺便说一句,它给出安全错误的原因是我们使用了一个使用 NHibernate 来验证基于用户的成员资格提供程序...

就像我经常遇到的情况一样,我花了很多时间来解决一个很容易解决的问题,它让我的脸颊发红...感谢至少 Ladislav 的帮助!

【讨论】:

    猜你喜欢
    • 2011-03-02
    • 1970-01-01
    • 1970-01-01
    • 2010-12-30
    • 1970-01-01
    • 1970-01-01
    • 2017-08-23
    • 1970-01-01
    • 2011-02-05
    相关资源
    最近更新 更多