高分求助 WCF Security IIS Host问题
创建证书
makecert -r -pe -n "CN=MyCert" -ss My -sky exchange
服务器端配置文件
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBindingConfiguration">
<security>
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="AFH.WCF.ServiceLibrary.Service">
<endpoint address="http://localhost/AFH.WCF.Server/Service.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfiguration"
contract="AFH.WCF.ServiceLibrary.IService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" />
</clientCertificate>
<serviceCertificate findValue="MyCert" storeLocation="CurrentUser" storeName="My"
x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="AFH.WCF.ServiceLibrary.MyUserNamePasswordValidator,AFH.WCF.ServiceLibrary" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
使用IIS Host,在IIS里浏览 Service.svc 报错
Cannot find the X.509 certificate using the following search criteria: StoreName 'My', StoreLocation 'CurrentUser', FindType 'FindBySubjectName', FindValue 'MyCert'.
看到过一个帖子说使用WinHttpCertCfg.exe 工具,尝试了还是不行,请高手帮帮忙!