ssl - 为什么在作为 Windows 服务托管的休息服务上添加基于证书的身份验证,无法启动服务?

标签 ssl windows-services wcf-ria-services wcf-binding wcf-security

我已经创建了 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 服务并尝试启动它。它会抛出错误。

enter image description here

我删除了以下部分

<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.

https://msdn.microsoft.com/en-us/library/ff648498.aspx

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

相关文章:

c# - Windows 服务最佳实践

silverlight - Windows 身份验证未加载用户

apache - SSL 库错误( key 值不匹配),但证书文件匹配

java - weblogic证书导入问题

c# - NancyFX 和 IPv6 问题

c# - 用 c# .NET 4 vs2010 编写的 Windows 服务不会安装在 Server 2008 R2 Enterprise 上

.net - 如何在.Net中为Windows服务创建Web界面?

node.js - Node 检索旧 TLS 证书

c# - 如果您创建一个 DomainService,公开一个实体,您可以访问聚合实体吗?

wcf - RIA 服务 OData "Query options are not allowed."