C# 使用ssl在本地IIS中托管wcf
我正在学习WCF,我需要创建一个带有https绑定的简单WCF服务。需要让它尽可能安全 到目前为止,我使用以下指南成功创建了一个自托管wcf: 设法把它吃掉,一切看起来都很好。但是,当我尝试在IIS8中托管时,真正的问题出现了。本地IIS,而不是IIS express 我在visual studio 2012中创建了一个新的wcf应用程序,在项目的属性->Web->服务器中,我选择了本地IIS,项目URL:https://localhost/AdminService ,创建虚拟目录 这在IIS管理器的默认网站下添加了一个应用程序。问题是,使用与我的自托管应用程序相同的web配置(经过粗略修改)不起作用。 经过一点修改后,我得出以下结论:C# 使用ssl在本地IIS中托管wcf,c#,wcf,ssl,https,iis-8,C#,Wcf,Ssl,Https,Iis 8,我正在学习WCF,我需要创建一个带有https绑定的简单WCF服务。需要让它尽可能安全 到目前为止,我使用以下指南成功创建了一个自托管wcf: 设法把它吃掉,一切看起来都很好。但是,当我尝试在IIS8中托管时,真正的问题出现了。本地IIS,而不是IIS express 我在visual studio 2012中创建了一个新的wcf应用程序,在项目的属性->Web->服务器中,我选择了本地IIS,项目URL:https://localhost/AdminService ,创建虚拟目录 这在IIS管
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="Certificate"/>
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WCFServiceCertificate.SecureServiceBehavior"
name="AdminService.AdminService">
<!--<host>
<baseAddresses>
<add baseAddress="https://localhost:1234/AdminService" />
</baseAddresses>
</host>-->
<endpoint address="https://localhost/AdminService" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding"
contract="AdminServiceContract.IAdminService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
<!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />-->
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFServiceCertificate.SecureServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" />
</clientCertificate>
<serviceCertificate findValue="CertAdminService" storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IAdminService">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="Certificate" />
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost/AdminService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAdminService"
contract="AdminServiceContract.IAdminService" name="WSHttpBinding_IAdminService" behaviorConfiguration="CustomBehavior">
<identity>
<dns value="WCfServer" />
</identity>
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="CustomBehavior">
<clientCredentials>
<clientCertificate findValue="CertAdminService" x509FindType="FindBySubjectName"
storeLocation="LocalMachine" storeName="My" />
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>