我已经创建了 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.
关于ssl - 为什么在作为 Windows 服务托管的休息服务上添加基于证书的身份验证,无法启动服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40528181/