简体   繁体   English

验证邮件的安全性时发生错误

[英]An error occurred when verifying security for the message

When I try to call a WCF service I am getting the following message "An error occurred when verifying security for the message." 当我尝试调用WCF服务时,我收到以下消息“验证邮件的安全性时出错”。

When I remove the custom authenication the service works no problem. 当我删除自定义身份验证时,该服务没有问题。 I can't figure out though what I have misconfigured in my web.config. 虽然我在web.config中配置错误,但我无法弄清楚。 Any insight would be appreciated. 任何见解将不胜感激。

  <system.serviceModel>
     <services>
        <service behaviorConfiguration="NAThriveExtensions.nableAPIBehavior"
          name="NAThriveExtensions.nableAPI">
           <endpoint 
             address="" 
             binding="basicHttpBinding" 
             bindingConfiguration="basicHttpBinding_Secure"
             contract="NAThriveExtensions.InableAPI">
           </endpoint>
           <endpoint 
             address="mex" 
             binding="mexHttpsBinding" 
             contract="IMetadataExchange" />
        </service>
     </services>
     <behaviors>
        <serviceBehaviors>
          <behavior name="NAThriveExtensions.nableAPIBehavior">
            <serviceMetadata httpsGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="false" />
            <serviceCredentials>
              <userNameAuthentication 
                userNamePasswordValidationMode="Custom" 
              customUserNamePasswordValidatorType= "NAThriveExtensions.Authentication, NAThriveExtensions" />
            </serviceCredentials>
          </behavior>
        </serviceBehaviors>
     </behaviors>
     <bindings>
       <basicHttpBinding>
         <binding name="basicHttpBinding_Secure">
           <security mode="TransportWithMessageCredential">
             <message clientCredentialType="UserName"/>
           </security>
         </binding>
       </basicHttpBinding>
     </bindings>
  </system.serviceModel>

I was getting this same error message and it turned out to be due to a time difference between my workstation machine and the server hosting the WCF service. 我收到同样的错误消息,结果是由于我的工作站机器和托管WCF服务的服务器之间的时间差异。 The server was about 10 minutes behind my machine and WCF security doesn't seem to like that very much. 服务器在我的机器后面大约10分钟,WCF安全性似乎不太喜欢。

To find the root problem I turned on serviceSecurityAuditing in the server's config file. 为了找到根问题,我在服务器的配置文件中打开了serviceSecurityAuditing Add the following to the configuration/system.serviceModel/behaviors/serviceBehaviors/behavior section for your service: 将以下内容添加到服务的configuration / system.serviceModel / behavior / serviceBehaviors / behavior部分:

<serviceSecurityAudit 
    auditLogLocation="Application" 
    serviceAuthorizationAuditLevel="Failure" 
    messageAuthenticationAuditLevel="Failure" 
    suppressAuditFailure="true"/>

The following site was helpful in figuring this out: 以下网站有助于解决这个问题:

http://blogs.microsoft.co.il/blogs/urig/archive/2011/01/23/wcf-quot-an-error-occurred-when-verifying-security-for-the-message-quot-and-service-security-audit.aspx http://blogs.microsoft.co.il/blogs/urig/archive/2011/01/23/wcf-quot-an-error-occurred-when-verifying-security-for-the-message-quot-and-服务安全audit.aspx

Another cause of this message is when some of your machines are not synchronized in time. 此消息的另一个原因是您的某些计算机未及时同步。 WCF, by default, allows a five-minute gap; 默认情况下,WCF允许五分钟的差距; beyond this, it throws an error if things are out of synch. 除此之外,如果事情不同步,它会抛出错误。

The solution is to synch all your machines. 解决方案是同步所有机器。 time.windows.com is notorious for not working, so I suggest using something else. time.windows.com因不工作而臭名昭着,所以我建议使用别的东西。 (If you're in a corporate environment, a local domain controller may be the correct choice here.) (如果您在公司环境中,本地域控制器可能是正确的选择。)

This ended up being an problem on the consuming side, not with the service itself. 这最终成为消费方面的问题,而不是服务本身。 Software AG's webMethods 8 was consuming this server but there was no Security Handler added to the service so the credentials were not being added to the header thus resulting the in the aforementioned error. Software AG的webMethods 8正在使用此服务器,但没有向服务添加安全处理程序,因此凭据未添加到标头中,从而导致上述错误。

I was getting the same error on my IIS 7.5 server. 我在IIS 7.5服务器上遇到了同样的错误。 I forgot to add Read permission on the certificate's private key to the app pool virtual account (eg IIS AppPool\\ASP.NET v4.0). 我忘了将证书私钥的读取权限添加到应用程序池虚拟帐户 (例如IIS AppPool \\ ASP.NET v4.0)。

For info, whilst testing various combinations of accounts and permissions, I noticed that the app pool needed to be recycled to lose access to the key, once it had been retrieved once. 有关信息,在测试帐户和权限的各种组合时,我注意到,一旦检索到应用程序池,就需要回收它以失去对密钥的访问权限。

(0x80131501 - An error occurred when verifying security for the message.) (0x80131501 - 验证邮件的安全性时发生错误。)

I was getting the same error and none of the above help for me. 我得到了同样的错误,上面没有任何帮助。

I finally tracked it down to connectionStrings in a parent web.config (my service was deployed to a child application to an admin site). 我最终在父web.config中将其跟踪到connectionStrings(我的服务部署到子应用程序到管理站点)。

Yes sounds ridiculous, but as soon as I wrapped the connection strings in the parent web.config with a location element all started working. 是的听起来很荒谬,但只要我在父web.config中包含连接字符串并且一个位置元素全部开始工作。

For clarity, in parent web.config, I changed this 为清楚起见,在父web.config中,我改变了这一点

<connectionStrings>
    <add name="..." />
</connectionStrings>

to this 对此

<location path="." inheritInChildApplications="false">
    <connectionStrings>
        <add name="..." />
    </connectionStrings>
</location>

Note this error also resulted in this very unhelpful serviceSecurityAudit log message: 注意这个错误也导致了这个非常无用的serviceSecurityAudit日志消息:

Message authentication failed. 邮件验证失败。
Service: ... 服务:......
Action: http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT 行动: http//schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT
ClientIdentity: CLIENTIDENTITY:
ActivityId: ActivityId:
ArgumentNullException: Value cannot be null. ArgumentNullException:值不能为null。
Parameter name: manager 参数名称:manager

I was getting the same error. 我得到了同样的错误。 I forgot to add Read permission on the membership database aspnetdb to the (IIS APPPOOL\\DefaultAppPool). 我忘了将成员资格数据库aspnetdb的读取权限添加到(IIS APPPOOL \\ DefaultAppPool)。

Message authentication failed. 邮件验证失败。 Service:.... 服务:....

Action: http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT 行动: http//schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT

ClientIdentity: CLIENTIDENTITY:

ActivityId: ActivityId:

SqlException: Cannot open database "aspnetdb" requested by the login. SqlException:无法打开登录请求的数据库“aspnetdb”。 The login failed. 登录失败。

Login failed for user 'IIS APPPOOL\\DefaultAppPool'. 用户'IIS APPPOOL \\ DefaultAppPool'登录失败。

I had a similar issue. 我有一个类似的问题。 I was building my datetime formatted strings using my local time , but my service/server was expecting GMT . 我使用当地时间构建我的日期时间格式化字符串,但我的服务/服务器期待GMT

I needed to get the GMT time (JAVA): 我需要获得GMT时间(JAVA):

final Date currentTime = new Date();    
final SimpleDateFormat sdf = 
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.000Z'");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println(sdf.format(currentTime));

用户名和密码是您连接的服务器 ,而不是您的系统登录用户名和密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 验证CRM Online中消息的安全性时发生错误 - Error occurred when verifying security for the message in CRM On-line WCF 身份验证 - 验证消息的安全性时出错 - WCF Authentication - An error occurred when verifying security for the message WCF-具有用户名确认和消息的wsHttpBinding-错误消息“处理消息中的安全令牌时发生错误” - WCF - wsHttpBinding with UserName Autentication and Message - error message “An error occurred when processing the security tokens in the message” 错误:安全处理器无法在消息中找到安全标头 - error :Security processor was unable to find a security header in the message WCF错误 - 安全处理器无法在消息中找到安全标头 - WCF Error - Security processor was unable to find a security header in the message 使用Metro客户端缓冲传入的SOAP消息时发生错误 - Error occurred while buffering incoming SOAP message using Metro client 使用消息安全性时的WS-Security开销 - WS-Security overhead when using message security 在WCF中使用消息级安全性时是否需要传输级安全性? - Is Transport Level Security Necessary When Using Message Level Security in WCF? 具有消息(用户名)安全性的 Trustchain 错误 NetTcpBinding - Trustchain error NetTcpBinding with message (username) security WCF 错误 - 消息安全验证失败 - WCF Error - Message security verification failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM