如果我需要向证书授予如下所述的附加权限,我应该在 Powershell 中从哪里开始?必须有一个 Windows 命令行可执行文件,我必须从命令行启动它。只有这样我才能考虑用powershell脚本编写它,对吧?
- Click Start, type mmc in the Search programs and files box, and then press ENTER.
- On the File menu, click Add/Remove Snap-in.
- Under Available snap-ins, double-click Certificates.
- Select Computer account, and then click Next.
- Click Local computer, and then click Finish. Click OK.
- Under Console Root, Certificates (Local Computer), in the Personal store, click Certificates.
- Right-click xxAzurehost1 certificate that has been created earlier. Choose All Tasks > Manage Private Keys. Click Add and then Advanced. Click Locations and choose your local computer. Click Find Now. Select NETWORK SERVICE in the search results and click OK. Click OK. In the Permissions for xxxazurehost1 private keys window, select NETWORK SERVICE and give Read permissions. Click OK.
最佳答案
要控制私钥的 ACL,您只需编辑文件 ACL。诀窍是找到哪个文件。
私钥存储在:
%ProgramData%\Microsoft\Crypto
在 XP 上:
C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto
在此处您将看到按算法组织的键,例如DSS、RSA。
用户存储将是带有用户 SID 的子文件夹。本地计算机存储将位于子文件夹中:
MachineKeys
以下是获取存储证书私钥信息的文件的方法。
首先进入本地机器个人证书存储:
PS> cd cert:\LocalMachine\My
现在您必须获取您的证书的句柄。执行此操作的方法不止一种,这里是使用指纹的一种方法:
$cert = dir | ? {$_.Thumbprint -eq "232820EEBF7DBFA01EE68A28BA0450671F862AE1"}
现在您可以找到如下私钥文件名:
$fileName = $cert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName $keyFile = dir -Path "C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto" -Recurse | ? {$_.Name -eq $fileName}
$keyFile 将是 FileInfo 对象,您可以使用 Set-ACL 或 icacls.exe 更改 ACL
关于powershell - 从哪里开始为此创建 Powershell 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8376468/