无法使用SSL访问WCF服务

时间:2012-09-07 14:08:59

标签: c# wcf

我使用SSL创建了一个WCF服务。我可以编译并启动该服务。但是,我无法在网络浏览器中点击它。它只是说"与192.168.1.12的连接被中断了。"我确保我的浏览器已启用它,并且它可以在其他使用SSL的网站上运行。我是WCF服务的新手,因此任何有关故障排除的建议或提示都会有所帮助。

我没有使用IIS **

以下是我的网络配置信息:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="WSHttpBinding_IApplicationService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="6553600" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="Certificate" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <services>
      <service name="Application.ServiceModel.ApplicationService" behaviorConfiguration="ApplicationServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="https://192.168.1.12:8000/ApplicationServiceModel/service" />
          </baseAddresses>
        </host>
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="WSHttpBinding_IApplicationService" contract="Application.ServiceModel.IApplicationService" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ApplicationServiceBehavior">
          <serviceMetadata httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

1 个答案:

答案 0 :(得分:1)

自签名证书通常被视为无效,仅用于测试。

在wcf中,您可以使用以下内容忽略证书错误(在客户端上)。

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

但是,它只应用于测试。在生产环境中,您希望获得由受信任的证书颁发机构签名的证书。