我需要设置一个部署脚本来导入我的服务使用的SSL证书。 我试图用WinHttpCertCfg和CertMgr导入无济于事。
以下是我尝试使用的命令行参数:
winhttpcertcfg.exe -i <certname>.pfx -c LOCAL_MACHINE\My -p <password> -a <user service runs as>
和
CertMgr.exe -add -all -s -r localMachine -c <cert name> My
从我所调查的看来,CertMgr不允许你使用密码导入证书,所以我宁愿让winhttpcertcfg工作。
当我运行它们时,我得到以下输出:WinHttpCertCfg:
Microsoft (R) WinHTTP Certificate Configuration Tool Copyright (C) Microsoft Corporation 2001.
CertMgr:
CertMgr Succeeded
但是,当我查看MMC中的本地机器证书时,尝试从我的服务中加载它们,或者通过winhttpcertcfg列出它,甚至在HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ SystemCertificates \ MY \ Certificates中查找registry。
我已经尝试了以下所有内容:
在这一点上,我正式出于想法。
谢谢。
我find了答案:
事实certificate,winhttpcertcfg用于安装证书和Win 2008的库后端存在问题。还有一种替代方法,就是使用Powershell安装证书。 您可以编写一个脚本来使用x509Certificate2 .NET类,并将证书导入任何您想要的商店。 这种方法也给你更多的灵活性来做任何你需要的额外的检查。
更多细节在这里 。
总是有CertUtil.exe:
CertUtil -p Password -ImportPFX File.pfx
欲了解更多选项,请看这里:
http://technet.microsoft.com/en-us/library/cc732443.aspx
或者尝试:
CertUtil -ImportPFX -?