我创建了WCF REST服务并作为
Windows服务托管.我从以下帖子中获取了参考资料.
http://www.codeproject.com/Tips/1009004/WCF-RESTful-on-Windows-Service-Host
现在我正在尝试添加基于证书的身份验证.
我在配置文件中添加了以下部分.
注意:我按照以下msdn链接添加了验证
https://msdn.microsoft.com/en-us/library/ff648360.aspx
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security>
<message clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
和
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<serviceCertificate findValue="CN=tempCertServer" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
我安装了Windows服务,并尝试启动它.它会引发错误.
我删除了以下部分
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<serviceCertificate findValue="CN=tempCertServer" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
并且错误消失了.显然认证不起作用.
可能是什么原因?
我正在为托管为Windows服务的休息服务正确添加基于证书的身份验证吗?
最佳答案
I got the solution.I made following change
<serviceDebug includeExceptionDetailInFaults="true" />
I saw the exception in event view logs. service was not able to find certificate,
hence not started.Again created certificate and it works.
For creating certificate follow following link closely.