我正在构建一个 WCF Restful Web 服务,目前,我正在通过 http 传输数据。现在,我想通过 https 安全地传输数据。我应该在我的配置文件中更改什么才能启用此功能?这是我当前的配置文件:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="MyService.DBService" behaviorConfiguration="ServiceBehaviour">
<endpoint address ="" binding="webHttpBinding" contract="MyService.IDBService" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
最佳答案
您必须通过定义自定义配置传输层安全性,并使用 bindingConfiguration 在端点中引用它。检查this关于配置安全性。一旦你有这个在你的 IIS 中配置一个 SSL 证书来完成这个。可以引用this查看如何使用 IIS 配置 SSL 证书。
关于wcf - 通过 SSL 配置 REST WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15791268/