[英]WCF Service with custom username password authentication problem
我正在尝试使用https以及用户名和密码来保护WCF服务。 我正在使用TransportWithMessageCredentials安全模式和wsHttpBinding。 现在,当我比较像这样的硬编码值时,我在使用自定义UserNamePasswordValidator时遇到了麻烦
if (userName == "user" && password == "pass")
return;
一切正常,但是当我尝试从数据库中获取值时,出现错误消息
接收到来自另一方的不安全或不正确安全的故障。 有关错误代码和详细信息,请参见内部FaultException。
这是我的web.config部分
<bindings>
<wsHttpBinding>
<binding name="TestAuthConf" maxReceivedMessageSize="65536">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
<readerQuotas maxArrayLength="65536" maxBytesPerRead="65536" maxStringContentLength="65536"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="TestAuthWCFService.TestAuthBehavior" name="TestAuthLibrary.App_Code.TestAuth">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="TestAuthConf" contract="TestAuthLibrary.App_Code.ITestAuth">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="TestAuthLibrary.App_Code.ITestAuth"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TestAuthWCFService.TestAuthBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="App_Code.CustomUserNameValidator, App_Code.CustomUserNameValidator"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
我正在使用IIS7,自行生成的数字证书,并且设置了SSL以接受客户端证书...
任何帮助都将适用...
好消息:如果您的自定义用户名/密码验证程序正在执行,则证书已经过验证,因此可以消除很多可能性。
在我看来,在WCF的线程上下文中访问数据库存在错误。 在验证器中设置一个断点并逐步执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.