【问题标题】:TLS handshake failure, CurrentUser works while LocalMachine does notTLS 握手失败,CurrentUser 工作,而 LocalMachine 不工作
【发布时间】:2021-11-14 02:16:47
【问题描述】:

我正在尝试将 WCF 客户端配置为使用证书与服务器进行安全通信。当证书位于 CurrentUser 证书存储区时,一切正常。我可以使用 Wireshark 查看握手是否发生,并且客户端/服务器通信按预期进行。

当我使用 LocalMachine 证书存储中的相同证书时,我收到错误 Could not establish secure channel for SSL/TLS with authority。使用 LocalMachine 证书存储时有什么特别需要考虑的吗?

这行得通:

<system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="endpointCredentialBehavior">
          <clientCredentials>
            <clientCertificate findValue="certTest"
                               storeLocation="CurrentUser"
                               storeName="My"
                               x509FindType="FindBySubjectName"/>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
<system.serviceModel>

这不是:

<system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="endpointCredentialBehavior">
          <clientCredentials>
            <clientCertificate findValue="certTest"
                               storeLocation="LocalMachine"
                               storeName="My"
                               x509FindType="FindBySubjectName"/>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
<system.serviceModel>

证书已签名,CA 证书放置在 CurrentUserLocalMachine 证书存储的 Trusted Root Certification Athorities 存储中.

【问题讨论】:

    标签: wcf ssl certificate certificate-store


    【解决方案1】:

    原来,当证书添加到 LocalMachine 证书存储时,证书是由管理员帐户添加的。 但是当 WCF 客户端运行时,客户端以普通用户的身份运行。普通用户的帐户无权访问证书的私钥。为了完成 TLS 握手,用户必须有权访问私钥。

    要让其他用户访问私钥,请右键单击证书管理器中的证书,然后选择:所有任务 -> 管理私钥... 对于具有关联私钥的证书,您只会看到“管理私钥...”选项。

    【讨论】:

    • 如果我理解正确,当有其他用户要访问时,证书权限需要向管理员申请,否则他们无法访问,您要过滤掉通过身份验证可以访问的用户机制。
    • 据我了解,管理员是否有权访问并不重要。重要的部分是,如果用户 A 添加了私钥,但用户 B 将使用该私钥,则需要为用户 B 提供对私钥的显式访问权限。
    • 是的,创建证书时也需要指定-sky exchange。
    猜你喜欢
    • 2020-08-20
    • 2019-12-16
    • 2015-01-04
    • 1970-01-01
    • 2018-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    相关资源
    最近更新 更多