Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将wcf服务从Http更改为https会使其无法访问_C#_Wcf - Fatal编程技术网

C# 将wcf服务从Http更改为https会使其无法访问

C# 将wcf服务从Http更改为https会使其无法访问,c#,wcf,C#,Wcf,由于firefox中的“混合内容阻止”问题,我不得不将在控制台应用程序上运行的wcf服务更改为https 这是配置文件: <services> <service name="ServiceHost.Services.BiometricCaptureService" behaviorConfiguration="Default"> <endpoint address="rest" behaviorConfiguration="CorsBehavior" b

由于firefox中的“混合内容阻止”问题,我不得不将在控制台应用程序上运行的wcf服务更改为https

这是配置文件:

<services>
  <service name="ServiceHost.Services.BiometricCaptureService" behaviorConfiguration="Default">
    <endpoint address="rest" behaviorConfiguration="CorsBehavior" binding="webHttpBinding" bindingConfiguration="httpsBinding" contract="ServiceHost.IServices.IBiometricCaptureService"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="https://localhost:8502/biometrics/biometricscaptureservice.svc"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="CorsBehavior">
      <webHttp/>
      <crossOriginResourceSharingBehavior/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="Default">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<extensions>
  <behaviorExtensions>
    <add name="crossOriginResourceSharingBehavior" type="ServiceHost.Utility.CORSBehaviorExtensionElement, ServiceHost, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  </behaviorExtensions>
</extensions>
<bindings>
  <webHttpBinding>
    <binding name="httpsBinding" maxReceivedMessageSize="2147483647">
      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
      </security>
      <readerQuotas maxStringContentLength="2147483647" />
    </binding>
  </webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

启动服务不会引发此配置的任何错误,但我无法再点击端点

我能得到的唯一错误是:“无法从传输连接读取数据:远程主机强制关闭了现有连接。”


有人看到这有什么问题吗?

我不知道您的服务如何找到加密证书

你应该有这样的东西:

<behaviors>
 <serviceBehaviors>
   <behavior name="mySvcBehavior">
      <serviceCredentials>
        <serviceCertificate findValue="xxxxxx" x509FindType="FindByThumbprint" />
      </serviceCredentials>
   </behavior>
 </serviceBehaviors>
</behaviors>


这是在WCF站点上设置HTTPS的一个相当不错的分步指南

尝试添加
System.Net.ServicePointManager.ServerCertificateValidationCallback=((发件人、证书、链、sslPolicyErrors)=>true)
在您的控制台应用程序中,有什么方法可以避免安装证书并仍然能够使用HTTPS?没有。。。你需要一张证书。如果没有证书和让服务查找证书的编程,将安全性更改为“传输”,将端点更改为“HTTPS”并不意味着什么。但是,即使您将HTTPS与证书一起使用,如果证书是自生成的,Firefox仍然会抱怨证书没有从官方CA(证书颁发机构)发布。您可能必须将证书添加到受信任列表中。