wcf - 带有 ssl 和 webHttpBinding 的自托管 wcf

标签 wcf ssl

我已经创建了一个自托管的 WCF 服务,它充当具有 webHttpBinding 和 CORS 支持的 REST API 服务。我通过浏览器使用此服务。

当我尝试添加 https 时,它不起作用。

我创建了 CERTS,并根据本教程将它们组合起来:

https://www.youtube.com/watch?v=ugpPSNxtAmY

我的配置是:

<system.serviceModel>
<services>
  <service name="MyService.MyService">
    <endpoint address="" binding="webHttpBinding" contract="MyService.IMyService" behaviorConfiguration="jsonBehavior">
      <identity>
        <dns value="MyMachine" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
  </service>
</services>
<extensions>
  <behaviorExtensions>
    <add name="crossOriginResourceSharingBehavior" type="Company.Common.EnableCrossOriginResourceSharingBehavior, Company.Common" />
  </behaviorExtensions>
</extensions>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true.  Set to false before deployment 
      to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="jsonBehavior">
      <webHttp />
      <crossOriginResourceSharingBehavior />
    </behavior>
  </endpointBehaviors>
</behaviors>
<bindings>
  <webHttpBinding>
    <binding crossDomainScriptAccessEnabled="true" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="524288"
    transferMode="Buffered">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </webHttpBinding>
</bindings>
<standardEndpoints>
  <webScriptEndpoint>
    <standardEndpoint name="" crossDomainScriptAccessEnabled="true" />
  </webScriptEndpoint>
</standardEndpoints>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

当我尝试消费时出现错误。 我该怎么做。 该服务的客户端是浏览器

最佳答案

这个教程很棒:

http://www.allenconway.net/2012/05/creating-wcf-restful-service-and-secure.html

它准确地解释了应该做什么

关于wcf - 带有 ssl 和 webHttpBinding 的自托管 wcf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41380485/

相关文章:

c# - WCF Discovery : System. UriFormatException 使用带通配符 (*) 的 URI 创建 ServiceHost

c# - WCF 自定义 JSONP 绑定(bind)和 httpsTransport

android - 使用mysql数据库在远程服务器上托管Wcf服务并在Android中使用它

.net - RESTful WCF 的最低配置

python - 无法选择密码

.net - 在 PHP 中连接到具有 NetTCP 绑定(bind)和 BasicHttpBinding 的 WCF 服务

ssl - 在 Heroku 上使用自定义域设置 SSL 端点

amazon-web-services - GoDaddy 上的 AWS DNS 验证

.net - HTTPS 重定向在本地有效,但在 azure 上无效

firefox - 在 Firefox 的匿名配置文件上接受不受信任的证书