我有一个WCF(svs)Web服务,它运行在Windows 2008 IIS Web服务器上。如何在IIS上配置我的WCF(svc)服务以仅在HTTPS请求上提供服务?
IIS服务器已经安装了SSL证书,并通过HTTP和HTTPS托管经典ASP和PHP。
我已经将WCF服务安装为IIS服务器上的应用程序(位于同一个域中),并且它可以完美地同时使用HTTP和HTTPS提供请求。
但是,我希望此WCF服务仅用于提供HTTPS请求和响应。
我需要在WCF的web.config中做些什么来改变它?
UPDATE
从我上面的帖子,我已经成功地研究出现使用web.config文件的工作如下继;
<system.serviceModel>
<services>
<service behaviorConfiguration="returnFaults" name="MyService.MonitorService">
<endpoint binding="wsHttpBinding" bindingConfiguration=
"TransportSecurity" contract="MyService.IMonitorSvc" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<!-- 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>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
任何人都可以证实这是一个WCF服务的正确做法,强制执行,所有的请求都通过HTTPS(SSL)制造?
基本上使用上述内容,用户是否可以向服务发出HTTP请求?或者服务总是强制执行HTTPS
感谢您的澄清。
使用IIS URL重定向来匹配所有http://请求并重定向到https://? – NWard
我的偏好是不在IIS中强制执行HTTPS,因为如果我将服务移动到另一个域,我需要再次配置IIS,这可能是一些被遗忘的事情。我倾向于在代码/ web.config中以某种方式执行此操作 – Tommassiov
IIS URL重定向仅将节点附加到应用程序的web.config文件,因此它应该很容易移植。 –
NWard