【发布时间】:2013-12-16 00:32:58
【问题描述】:
我想要一个 WCF 服务,所有请求都经过验证、授权和仅通过 https 发送。
我为 SLL 生成了证书。对于开发,我使用的是 ISS Express。
同样在 web.config 中,我将任何 http 选项设置为 false。但仍然在生成的 WSDL 中,当我使用 WCFStorm 检查服务方法时,它仍然使用http://localhost:1947 而不是我声明的https://localhost:44300。我需要更改什么以确保所有通信都通过 https?
这是我的 web.config 文件:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="secureBinding">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="AF.Services.AFService" behaviorConfiguration="AFServiceBehavior">
<endpoint address="AFService.svc"
binding="wsHttpBinding"
contract="AF.Common.Services.IAFService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="AFServiceBehavior">
<serviceCredentials>
<serviceCertificate findValue="AFCert"
x509FindType="FindBySubjectName" storeLocation="LocalMachine"
storeName="My" />
<userNameAuthentication
userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="AF.Services.UserValidator, AF.Services" />
</serviceCredentials>
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
<!-- TODO zmienić przed deployem!!-->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
描述如何使用该服务的网页只能通过 44300 https 端口访问。
【问题讨论】:
-
我相信你需要
<securityMode="TransportWithMessageCredential">来强制只使用 SSL。
标签: c# wcf web-services https wsdl