从命令行设置证书的读权限

时间:2011-08-31 10:36:18

标签: windows certificate file-permissions acl

有人能指出我从命令行管理证书读取权限的正确方向吗?我正在编写我们的证书安装脚本,并且需要允许NetworkService访问“本地计算机\个人\证书”存储中的2个证书。

提前致谢

1 个答案:

答案 0 :(得分:4)

我已经这样做了,以便我们的Web应用程序可以访问Windows中安装的证书的私钥。

这是一个powershell脚本。它依赖于Microsoft的FindPrivateKey.exe

# Use FindPrivateKey.exe (From Windows SDK) to get the file name of the private key.
$s = cmd /c "FindPrivateKey.exe My LocalMachine -t   `"9D1F685D554E5B04C591D7967FB0D151153A25D8`" -a"

# Grant read access on the private key
cmd /c "cacls.exe `"$s`" /E /G `"IIS_IUSRS`":R"