Грешка в Https сертификата, WCF услуга на IIS

Искам да организирам защитена връзка между клиент и WCF услуга. Клиентът трябва да е сигурен, че може да се довери на услугата.

Създадох два сертификата за Trusted Root и за лични хранилища на локалната машина. Виждам правилния път за сертифициране в добавката за сертификат. Общото име на сертификата е localhost.

Добавих обвързването за https на IIS.

Имам услугата със следната конфигурация

Поведение

    <behavior name="AgencyTrustedServiceBehavior">
      <dataContractSerializer maxItemsInObjectGraph="10000000" />
      <serviceMetadata httpsGetEnabled="true" policyVersion="Policy15" />
      <serviceDebug includeExceptionDetailInFaults="true" />

      <serviceCredentials>
        <clientCertificate>
          <authentication certificateValidationMode="None"  />
        </clientCertificate>

        <serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />

      </serviceCredentials>
    </behavior>

Подвързване

  <wsHttpBinding>
    <binding name="InternetServiceBinding" closeTimeout="00:10:00"
          openTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="true"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Mtom">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="None">
          <extendedProtectionPolicy policyEnforcement="Never" />
        </transport>
      </security>
    </binding>
  </wsHttpBinding>

Крайна точка

  <service behaviorConfiguration="AgencyTrustedServiceBehavior" name="Megatec.MasterTourService.AuthService">
    <endpoint address="Anonymous" 
              binding="wsHttpBinding" 
              bindingConfiguration="InternetServiceBinding" 
              name="Megatec.MasterTourService.Contracts.IAuthServiceAnonymous" 
              contract="Megatec.MasterTourService.Contracts.IAuthService">
    </endpoint>
  </service>

Но когато се опитам да осъществя достъп до услугата с помощта на WCFTestClient, тя хвърля следното изключение

There was no endpoint listening at http://localhost/IISTest/AuthService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.    The remote server returned an error: (404) Not Found.

HTTP GET Error    URI: http://localhost/IISTest/AuthService.svc    The document at the url http://localhost/IISTest/AuthService.svc was not recognized as a known document type.The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
- Report from 'DISCO Document' is 'There was an error downloading 'https://dev4-10.megatec.ru/IISTest/AuthService.svc?disco'.'.  
- The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.  
- The remote certificate is invalid according to the validation procedure.
- Report from 'http://localhost/IISTest/AuthService.svc' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

Какво не е наред?


person Sir Hally    schedule 26.12.2012    source източник
comment
Като за начало, не трябва ли да използвате https?   -  person 500 - Internal Server Error    schedule 26.12.2012
comment
Използвам https. Добавих https-binding за IIS (с този сертификат), опитвам се да осъществя достъп до localhost/IISTest/AuthService.svc адрес   -  person Sir Hally    schedule 26.12.2012


Отговори (1)


URL адресът, който клиентът посещава, е:

"http://localhost/IISTest/AuthService"

Трябва да бъде

"https://localhost/IISTest/AuthService"

person Thilak Nathen    schedule 26.12.2012
comment
Реших това - тестовият клиент на WCF автоматично използва localhost/IISTest/AuthService.svc вместо localhost/IISTest/AuthService.svc. Когато съм добавил услугата с адрес localhost/IISTest/AuthService, тя работи. - person Sir Hally; 26.12.2012