2011-05-13 56 views
2

我已经使用HTTPS/SSL,传输安全性和基本身份验证创建了自托管的WCF服务。出于某种原因,当我在浏览器中运行该服务时,它从不要求凭据。怎么了?WCF自托管服务SSL /传输安全性/基本身份验证不要求凭据

服务配置:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="WsHttpTest.GreetingServiceBehavior"> 
      <serviceMetadata httpsGetEnabled="True"/> 
      <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="TransportSecurity"> 
      <security mode="Transport"> 
      <transport clientCredentialType="Basic"/> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="WsHttpTest.GreetingServiceBehavior" name="WsHttpTest.GreetingService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="https://localhost:8555/WsHttpTest/Greeting" /> 
      </baseAddresses> 
     </host> 
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="WsHttpTest.IGreetingService" /> 
     <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    </system.serviceModel> 
</configuration> 

HTTP配置:

C:\>httpcfg query ssl 
    IP      : 0.0.0.0:8555 
    Hash     : 14ae237add3c49 a5091367487563cf6f6a8f586 
    Guid     : {9416496a-6d3e-4680-a9d1-03defd97d7d6} 
    CertStoreName   : MY 
    CertCheckMode   : 0 
    RevocationFreshnessTime : 0 
    UrlRetrievalTimeout  : 0 
    SslCtlIdentifier  : 
    SslCtlStoreName   : 
    Flags     : 0 
------------------------------------------------------------------------------ 
C:\>httpcfg query urlacl 
    URL : https://localhost:8555/WsHttpTest/Greeting/ 
    ACL : D:(A;;GX;;;WD) 
------------------------------------------------------------------------------ 

回答

2

如果用=你创建代理和调用运行暴露的服务合同和端点通信的wsHttpBinding配置仅使用。打开服务的帮助页面时,您不会与端点进行通信。

ServiceMetadataBehavior还提供了两个附加属性HttpsHelpPageBindingHttpsHelpPageBindingConfiguration。也许如果你玩这些属性并为它们配置一些自定义绑定(必须是自定义的,因为它需要MessageVersion.None),你将能够强制帮助页面要求身份验证,但我从来没有尝试过。

我就开始喜欢的东西:

<bindings> 
    <cutstomBinding> 
    <binding name="helpPage"> 
     <textMessageEncoding messageVersion="None" /> 
     <httpsTransport authenticationScheme="Basic" /> 
    </binding> 
    </customBinding> 
</bindings>