Le service auto-hébergé WCF SSL/sécurité du transport/authentification de base ne demande pas d'informations d'identification

StackOverflow https://stackoverflow.com/questions/5998171

Question

J'ai créé un service WCF auto-hébergé avec HTTPS/SSL, sécurité du transport et authentification de base.Pour une raison quelconque, lorsque j'exécute le service dans le navigateur, il ne demande jamais d'informations d'identification.Qu'est-ce qui ne va pas?

Configuration des services :

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

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)
------------------------------------------------------------------------------
Était-ce utile?

La solution

La configuration de wsHttpBinding est utilisé uniquement si vous communiquez avec le point de terminaison = vous créez le proxy et appelez l'opération exposée sur le contrat de service.Lorsque vous ouvrez la page d'aide du service, vous ne communiquez pas avec le point final.

ServiceMetadataBehavior propose également deux propriétés supplémentaires HttpsHelpPageBinding et HttpsHelpPageBindingConfiguration.Peut-être que si vous jouez avec ces propriétés et configurez une liaison personnalisée (elle doit être personnalisée car elle nécessite MessageVersion.None) pour eux, vous pourrez également forcer la page d'aide à exiger une authentification, mais je ne l'ai jamais essayé.

Je commencerais par quelque chose comme :

<bindings>
  <cutstomBinding>
    <binding name="helpPage">
      <textMessageEncoding messageVersion="None" />
      <httpsTransport authenticationScheme="Basic" />
    </binding>
  </customBinding>
</bindings>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top