![](/img/trans.png)
[英]IIS 7.x, adding an HTTPS-enabled site: SiteCollection.Add(string, string, string, byte[]) overload
[英]HTTPS-enabled, IIS hosted WCF service, How to secure it?
我建立了一个相当简单的WCF服务,该服务托管在IIS 7.5实例上。 我已经完成了必要的步骤来保护SSL证书以启用https。 我已经解决了所有各种DNS设置,因此现在可以从世界各地的给定Https:// URL进入WCF了。 目标是:为大约5个将数据发送到服务的客户端进行某种客户端/服务器身份验证。 确保这项服务的最佳方法是什么? 此时,只有一种方法非常简单。 我确定web.config以及背后的代码都会有所变化。 实例不胜感激。
这是Web.config
<!-- language: lang-xml -->
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="wcflistener.Service1">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="wcflistener.IService1"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<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="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
和非常简单的Service1.svc.cs
[DataContract]
public class Service1 : IService1
{
public void SampleMethod(DataTable table, string name)
{
//sample method logic here
}
}
使用WCF,您可以使用几种安全选项,各有其优缺点:
这取决于您需要的身份验证级别。 对于很少的客户,用户名/密码就足够了。 (始终有失去这些风险)
对于主要客户2 SSL非常安全,因为人们不会轻易丢失私钥。
根据您的选择,可以共享其他代码示例。
对于选项#,请单击此链接。 (您可以在以下步骤中使用SSL证书)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.