Использовать WCF, защищенный сертификатом SSL, в приложении winform - PullRequest
1 голос
/ 02 декабря 2011

Я размещал WCF WCF в IIS 6.0.Я добавил ссылку на этот веб-сервис в приложение winform.Однако, когда я вызываю какой-либо метод моей службы, я получаю System.Net.WebException: запрос не выполнен с состоянием HTTP 403: Запрещено.

У меня установлен сертификат в моем личном хранилище.* Вот моя конфигурация сервера:

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IAwsService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>
    </binding>
  </basicHttpBinding>
  <wsHttpBinding>
    <binding name="TransportSecurity">
      <security mode="Transport">
        <transport clientCredentialType="Certificate"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://teclpo02.srr.fr:1098/AwsService/" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAwsService" contract="wsAws.IAwsService" name="BasicHttpBinding_IAwsService"/>
</client>
<services>
  <service name="AuthWorkStation_Wcf_Web.AwsService" behaviorConfiguration="ServiceBehavior">
    <endpoint name="" address="" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="AuthWorkStation_Wcf_Web.IAwsService" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceCredentials>
        <clientCertificate>
          <authentication certificateValidationMode="None" revocationMode="NoCheck" />
        </clientCertificate>
        <serviceCertificate storeName="Root" findValue="CA_SRR_DISTRIB" x509FindType="FindBySubjectName" />
      </serviceCredentials>
      <serviceMetadata httpsGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

Нужно ли мне редактировать файл winform app.config?Должен ли я написать какую-нибудь строку кода, чтобы сказать, где находится сертификат?

1 Ответ

1 голос
/ 02 декабря 2011

Проблема в том, что у вас есть транспортная безопасность, которая требует SSL / Https.Но ваш адрес http.

Измените свой адрес на https

Из кода, который вы отправили:

 <client> 
   <endpoint address="http://teclpo02.srr.fr:1098/AwsService/" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAwsService" contract="wsAws.IAwsService" name="BasicHttpBinding_IAwsService"/> 
 </client> 
<services> 

Вы также указали номер порта, который может быть заблокирован.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...