WCF SSL连接配置?

时间:2013-03-14 15:35:24

标签: c# wcf ssl-certificate

我写了wcf服务器和客户端应用程序,客户端和服务器都适用于基本的http绑定。 现在我想更改配置以使用SSL进行连接。 是否有任何机构可以解释我该怎么做并给出一个关于它的例子

非常感谢

2 个答案:

答案 0 :(得分:3)

以下是关于just thatnice post on Stack here的非常好的文章。

密钥将在您的Config文件中。

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicSecure">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="WcfServiceLibrary.Echo.EchoService">
        <endpoint 
          address="https://localhost:8888/EchoService/" 
          binding="basicHttpBinding"
          bindingConfiguration="BasicSecure" 
          contract="WcfServiceLibrary.Echo.IEchoService">
          <identity>
            <certificateReference 
              storeName="My" 
              storeLocation="LocalMachine"
              x509FindType="FindByThumbprint" 
              findValue="f1b47a5781837112b4848e61de340e4270b8ca06" />
          </identity>
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/" />
          </baseAddresses>
        </host>
      </service>
    </services>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
  </system.serviceModel>

这里需要注意的是security mode = "Transport"CertificateReference。那将是非常非常重要的。您必须确保正确配置您的端口才能使其正常工作。

请注意,wshttpBinding默认启用此加密。

祝你好运。

答案 1 :(得分:0)

http://www.codeproject.com/Articles/36705/7-simple-steps-to-enable-HTTPS-on-WCF-WsHttp-bindi 这是在WCF Serice上使用SSL的一个非常简单和基本的参考。 我和你不久前在同一条船上,关于SO的第一个问题是关于HTTP / HTTPS绑定。我与其中一位用户进行了很好的讨论,他们给了我一个很好的想法 看看这个。我有web配置,这是配置的主要配置 HTTP and HTTPS Bindings

希望这有帮助。