简体   繁体   中英

Why does the WCF service with the following configuration not work?

I have a WCF service with the below config file. Even though I have specified clientCredentialType = None , the WCF service (from VS2013), throws exception stating that certificate is not specified.

Why is it so? Shouldn't a certificate be required only if the clientCredentialType is set as Certificate.

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding>
          <security mode="Message">
            <message clientCredentialType="Windows"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="WCFBindingwshttpBinding.Service1">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="WCFBindingwshttpBinding.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/WCFBindingwshttpBinding/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

I think you are getting the error because you have not specified a Server certificate.

As I recall, WCF requires transport level security when using message encryption ( <security mode="Message"> ) in order to securely exchange the “shared secret” and establish the security context. Therefore, since you are using the WSHttpBinding , then the Server certificate is used to establish the security channel.

The following link provides good related information:
WCF message security without certificate and windows auth

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM