求助:WCF 安全之自定义的用户名/密码身份验证 中的identity dns怎么设置

服务器端使用证书来做“自定义用户名密码”认证方式,

ExpandedBlockStart.gif 服务端代码
   < system.serviceModel >
    
< bindings >
      
< wsHttpBinding >
        
< binding name = " NewBindingUName " >
          
< security mode = " Message " >
            
< transport clientCredentialType = " None "   />
            
< message clientCredentialType = " UserName "   />
          
</ security >
        
</ binding >
      
</ wsHttpBinding >
    
</ bindings >
    
< services >
      
< service behaviorConfiguration = " WcfServiceApp.ServicesBehavior "
        name
= " WcfServiceLib.Services " >
        
< endpoint address = ""  binding = " wsHttpBinding "  bindingConfiguration = " NewBindingUName "
          contract
= " WcfServiceLib.IServices " >
          
< identity >
            
< dns value = " 192.168.6.118 "   />
          
</ identity >
        
</ endpoint >
        
< endpoint address = " mex "  binding = " mexHttpBinding "  contract = " IMetadataExchange "   />
        
< host >
          
< baseAddresses >
            
< add baseAddress = " http://192.168.6.118/DotNet/OK/Test/WcfLibTest/WcfServiceApp/ "   />
          
</ baseAddresses >
        
</ host >
      
</ service >
    
</ services >
    
< behaviors >
      
< serviceBehaviors >
        
< behavior name = " WcfServiceApp.ServicesBehavior " >
          
< serviceMetadata httpGetEnabled = " true "   />
          
< serviceDebug includeExceptionDetailInFaults = " false "   />
          
< serviceCredentials >
            
< serviceCertificate findValue = " WCFServerCert "  storeLocation = " LocalMachine "
              storeName
= " My "  x509FindType = " FindBySubjectName "   />
            
< userNameAuthentication userNamePasswordValidationMode = " Custom "
              customUserNamePasswordValidatorType
= " WcfServiceLib.CustomUserPassword,WcfServiceLib "   />
            
< clientCertificate >
              
< authentication certificateValidationMode = " None " />
            
</ clientCertificate >
          
</ serviceCredentials >
        
</ behavior >
      
</ serviceBehaviors >
    
</ behaviors >
  
</ system.serviceModel >

 

 

 

 

客户端调用服务时,提示:

传出消息标识检查失败。所预期的远程终结点的 DNS 标识为“192.168.6.118”,但是远程终结点提供的 DNS 请求为“WCFServerCert”。如果此远程终结点合法,您可以通过在创建通道代理时明确地将 DNS 标识“WCFServerCert”指定为 EndpointAddress 的“标识”属性来解决此问题。 

ExpandedBlockStart.gif 客户端代码
     < system.serviceModel >
        
< bindings >
            
< wsHttpBinding >
                
< binding name = " WSHttpBinding_IServices "  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 "  establishSecurityContext = " true "   />
                    
</ security >
                
</ binding >
            
</ wsHttpBinding >
        
</ bindings >
        
< client >
            
< endpoint address = " http://alex/DotNet/OK/Test/WcfLibTest/WcfServiceApp/Services.svc "
                binding
= " wsHttpBinding "  bindingConfiguration = " WSHttpBinding_IServices "
                contract
= " Services.IServices "  name = " WSHttpBinding_IServices " >
                
< identity >
                    
< dns value = " 192.168.6.118 "   />
                
</ identity >
            
</ endpoint >
        
</ client >
    
</ system.serviceModel >

 

 

 



 

如果把“服务端”的

<identity>

            <dns value="192.168.6.118" />

</identity> 

去掉,就正确了,但总感觉这不是正解,有没有其它的解决办法?

 

 

 

转载于:https://www.cnblogs.com/webhuahua/archive/2010/09/02/1816173.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值