[英]An error occurred when verifying security for the message
當我嘗試調用WCF服務時,我收到以下消息“驗證郵件的安全性時出錯”。
當我刪除自定義身份驗證時,該服務沒有問題。 雖然我在web.config中配置錯誤,但我無法弄清楚。 任何見解將不勝感激。
<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>
我收到同樣的錯誤消息,結果是由於我的工作站機器和托管WCF服務的服務器之間的時間差異。 服務器在我的機器后面大約10分鍾,WCF安全性似乎不太喜歡。
為了找到根問題,我在服務器的配置文件中打開了serviceSecurityAuditing 。 將以下內容添加到服務的configuration / system.serviceModel / behavior / serviceBehaviors / behavior部分:
<serviceSecurityAudit
auditLogLocation="Application"
serviceAuthorizationAuditLevel="Failure"
messageAuthenticationAuditLevel="Failure"
suppressAuditFailure="true"/>
以下網站有助於解決這個問題:
此消息的另一個原因是您的某些計算機未及時同步。 默認情況下,WCF允許五分鍾的差距; 除此之外,如果事情不同步,它會拋出錯誤。
解決方案是同步所有機器。 time.windows.com
因不工作而臭名昭着,所以我建議使用別的東西。 (如果您在公司環境中,本地域控制器可能是正確的選擇。)
這最終成為消費方面的問題,而不是服務本身。 Software AG的webMethods 8正在使用此服務器,但沒有向服務添加安全處理程序,因此憑據未添加到標頭中,從而導致上述錯誤。
我在IIS 7.5服務器上遇到了同樣的錯誤。 我忘了將證書私鑰的讀取權限添加到應用程序池虛擬帳戶 (例如IIS AppPool \\ ASP.NET v4.0)。
有關信息,在測試帳戶和權限的各種組合時,我注意到,一旦檢索到應用程序池,就需要回收它以失去對密鑰的訪問權限。
(0x80131501 - 驗證郵件的安全性時發生錯誤。)
我得到了同樣的錯誤,上面沒有任何幫助。
我最終在父web.config中將其跟蹤到connectionStrings(我的服務部署到子應用程序到管理站點)。
是的聽起來很荒謬,但只要我在父web.config中包含連接字符串並且一個位置元素全部開始工作。
為清楚起見,在父web.config中,我改變了這一點
<connectionStrings>
<add name="..." />
</connectionStrings>
對此
<location path="." inheritInChildApplications="false">
<connectionStrings>
<add name="..." />
</connectionStrings>
</location>
注意這個錯誤也導致了這個非常無用的serviceSecurityAudit日志消息:
郵件驗證失敗。
服務:......
行動: http : //schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT
CLIENTIDENTITY:
ActivityId:
ArgumentNullException:值不能為null。
參數名稱:manager
我得到了同樣的錯誤。 我忘了將成員資格數據庫aspnetdb的讀取權限添加到(IIS APPPOOL \\ DefaultAppPool)。
郵件驗證失敗。 服務:....
行動: http : //schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT
CLIENTIDENTITY:
ActivityId:
SqlException:無法打開登錄請求的數據庫“aspnetdb”。 登錄失敗。
用戶'IIS APPPOOL \\ DefaultAppPool'登錄失敗。
我有一個類似的問題。 我使用當地時間構建我的日期時間格式化字符串,但我的服務/服務器期待GMT 。
我需要獲得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.