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

  <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>

相关文章:

  • 2022-01-07
  • 2021-07-03
  • 2021-09-14
  • 2021-12-19
  • 2021-07-29
  • 2021-07-12
  • 2021-08-02
  • 2022-12-23
猜你喜欢
  • 2021-09-22
  • 2021-06-07
  • 2022-03-04
  • 2021-05-31
  • 2022-12-23
相关资源
相似解决方案