0
我需要WCF的幫助!wsHttpBinding與自定義自動化,證書認證和消息傳輸安全
我用自定義授權和認證編寫了WCF服務。服務從Visual Studio啓動時運行良好,但是當我從任何主機(由我創建的Windows服務或主機)啓動時 - 引發下一個異常:
「收到來自無擔保或錯誤安全的故障另一方,查看故障代碼和細節的內部FaultException。「
內部異常:
「的消息驗證安全性時發生錯誤。」
服務配置(它的配置我複製到宿主app.cong):
<system.serviceModel>
<!--Binding with custom authentication-->
<bindings>
<wsHttpBinding>
<binding name="licenseServiceBinding">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="NS_SLM_Service.Service.LicenseService" behaviorConfiguration="customBehaviour">
<!--One service devided by a few contracts, because on a client need to separate API-functions-->
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="licenseServiceBinding" contract="NS_SLM_Service.Service.IAdminFunctions" />
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="licenseServiceBinding" contract="NS_SLM_Service.Service.IManagerFunctions" />
<endpoint address="http://localhost:8080/LicenseService/CommonFunctions" binding="basicHttpBinding" contract="NS_SLM_Service.Service.ICommonFunctions" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/LicenseService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="customBehaviour">
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="NS_SLM_Service.UserAuthorization,NS_SLM_Service" />
</authorizationPolicies>
</serviceAuthorization>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="NS_SLM_Service.UserAuthentication,NS_SLM_Service" />
<serviceCertificate findValue="tempCert" storeLocation="LocalMachine" x509FindType="FindBySubjectName" storeName="My" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
下一個代碼試圖連接到這個服務:
using (var proxy = new MyService())
{
proxy.ClientCredentials.UserName.UserName = "Login";
proxy.ClientCredentials.UserName.Password = "password";
proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
proxy.SomeMethod("Parametr");
}
我感到沮喪,因爲當我嘗試連接服務,當它在VS啓動,我沒有看到任何豁免...
謝謝。它可以幫助我。 –