【问题标题】:Consume WCF secured with SSL certificate in a winform application在 winform 应用程序中使用受 SSL 证书保护的 WCF
【发布时间】:2011-12-03 04:24:29
【问题描述】:

我在 IIS 6.0 中托管了一个 .svc WCF。我在 winform 应用程序中添加了对该 Web 服务的引用。但是,当我调用我的服务的任何方法时,我会收到 System.Net.WebException: The request failed with HTTP status 403: Forbidden。

我的个人商店中安装了证书。

这是我的服务器配置:

<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 文件吗?我是否必须编写一些代码来告诉证书在哪里?

【问题讨论】:

    标签: c# winforms wcf certificate


    【解决方案1】:

    问题是您的传输安全需要 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> 
    

    您还指定了该帖子可能被阻止的端口号。

    【讨论】:

    • 客户端部分用于在我的 wcf 中调用另一个 Web 服务。我可以通过在浏览器中键入HTTPS://myserver/Service.svc?wsdl 来读取我的安全 wcf 的 wsdl。所以我认为这不是这种情况下的问题。
    猜你喜欢
    • 2011-07-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多