C# 在winform应用程序中使用SSL证书保护的WCF

C# 在winform应用程序中使用SSL证书保护的WCF,c#,winforms,wcf,certificate,C#,Winforms,Wcf,Certificate,我在IIS6.0中托管了一个.svc WCF。我在winform应用程序中添加了对该web服务的引用。然而,当我调用我的服务的任何方法时,我得到一个System.Net.WebException:请求失败,HTTP状态403:禁止 我已将证书安装在个人存储中 这是我的服务器配置: <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBindin

我在IIS6.0中托管了一个.svc WCF。我在winform应用程序中添加了对该web服务的引用。然而,当我调用我的服务的任何方法时,我得到一个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文件吗?我需要写一些代码来告诉证书在哪里吗?

问题是您有需要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> 


您还指定了post可能被阻止的端口号。

问题在于您具有需要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> 


您还指定了post可能被阻止的端口号。

客户端部分用于调用我的wcf中的另一个web服务。通过键入,我可以在浏览器中读取安全wcf的wsdl。因此,我认为这不是本例中的问题。客户端部分用于调用我的wcf中的另一个web服务。通过键入,我可以在浏览器中读取安全wcf的wsdl。所以我认为这不是本案的问题。