【问题标题】:Ansible: Best way to detect if a certificate is already installed in the Certificate StoreAnsible:检测证书是否已安装在证书存储中的最佳方法
【发布时间】:2017-04-07 14:10:00
【问题描述】:

在等待the new certificate module 时,我们正在通过以下方式安装证书:

win_shell: Import-PfxCertificate -filepath "{{ certificatePath }}" -certStorelocation cert:\\localmachine\\My -password $(ConvertTo-SecureString -AsPlainText -Force -String "{{ organization_key }}")

这很好用,但是如果已经安装了证书,我还没有找到任何跳过任务的好方法。我知道你可以运行SET-LOCATION CERT:\LOCALMACHINE,它提供了对作为文件系统的证书存储的访问,但也可以执行creates=cert:\localmachine\path\to\my\cert 之类的操作?

这里最好的策略是什么?

【问题讨论】:

    标签: windows powershell ssl certificate ansible


    【解决方案1】:

    答案很简单: creates=Cert:\\LOCALMACHINE\\My\\{{ CertificateThumbprint }}

    【讨论】:

      【解决方案2】:

      Test-Path cmdlet 也适用于证书提供者:

      if (Test-Path cert:\localmachine\path\to\my\cert)
      {
      }
      

      【讨论】:

        猜你喜欢
        • 2012-04-18
        • 2014-01-27
        • 2013-01-31
        • 2011-09-09
        • 2012-07-04
        • 1970-01-01
        • 2010-09-23
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多