使用 winhttpcertcfg 授予多个 IIS 应用程序池对同一证书的权限

Grant Multiple IIS App Pools Permission to Same Certificate Using winhttpcertcfg

我有一个证书,我需要为我的 IIS C# .NET 应用程序安装和授予访问权限,以安全地连接到 FirstData。我不太了解证书,所以我 运行 命令看起来像这样:

"C:\path\winhttpcertcfg" -i "WS10012NNN._.1.p12" -c LOCAL_MACHINE\MY -a "my-server-name\IIS APPPOOL\App1" -p <cert password>  
"C:\path\winhttpcertcfg" -i "WS10012NNN._.1.p12" -c LOCAL_MACHINE\MY -a "my-server-name\IIS APPPOOL\App2" -p <cert password>  
"C:\path\winhttpcertcfg" -i "WS10012NNN._.1.p12" -c LOCAL_MACHINE\MY -a "my-server-name\IIS APPPOOL\App3" -p <cert password>  
"C:\path\winhttpcertcfg" -i "WS10012NNN._.1.p12" -c LOCAL_MACHINE\MY -a "my-server-name\IIS APPPOOL\App4" -p <cert password>  
"C:\path\winhttpcertcfg" -i "WS10012NNN._.1.p12" -c LOCAL_MACHINE\MY -a "my-server-name\IIS APPPOOL\App5" -p <cert password>  

"C:\path\winhttpcertcfg" -g -c LOCAL_MACHINE\MY -s "WS10012NNN._.1" -a "my-server-name\IIS APPPOOL\App1"  
"C:\path\winhttpcertcfg" -g -c LOCAL_MACHINE\MY -s "WS10012NNN._.1" -a "my-server-name\IIS APPPOOL\App2"  
"C:\path\winhttpcertcfg" -g -c LOCAL_MACHINE\MY -s "WS10012NNN._.1" -a "my-server-name\IIS APPPOOL\App3"  
"C:\path\winhttpcertcfg" -g -c LOCAL_MACHINE\MY -s "WS10012NNN._.1" -a "my-server-name\IIS APPPOOL\App4"  
"C:\path\winhttpcertcfg" -g -c LOCAL_MACHINE\MY -s "WS10012NNN._.1" -a "my-server-name\IIS APPPOOL\App5"  

但是,这似乎没有按预期工作。实际上,我最终为 3 个应用程序池执行了上述操作,然后又为另外 2 个应用程序池执行了上述操作。我的一些网站无法运行,但如果我只为一个网站重新运行命令,它会破坏其他网站。看来我不能让所有 5 个同时工作。

似乎正确的顺序实际上应该是一个 -i 命令,然后是 5 个 -g 命令。但我不确定,而且我在网上找不到任何多站点示例。 如何正确授予我的所有 5 个应用程序池使用证书的权限?

虽然我仍然不完全了解 winhttpcertcfg 及其开关的来龙去脉,但我能够解决我的问题。答案是执行一个 -i 命令,然后执行所有 -g 命令。像这样:

"C:\path\winhttpcertcfg" -i "WS10012NNN._.1.p12" -c LOCAL_MACHINE\MY -a "my-server-name\IIS APPPOOL\App1" -p <cert password> 

"C:\path\winhttpcertcfg" -g -c LOCAL_MACHINE\MY -s "WS10012NNN._.1" -a "my-server-name\IIS APPPOOL\App1"  
"C:\path\winhttpcertcfg" -g -c LOCAL_MACHINE\MY -s "WS10012NNN._.1" -a "my-server-name\IIS APPPOOL\App2"  
"C:\path\winhttpcertcfg" -g -c LOCAL_MACHINE\MY -s "WS10012NNN._.1" -a "my-server-name\IIS APPPOOL\App3"  
"C:\path\winhttpcertcfg" -g -c LOCAL_MACHINE\MY -s "WS10012NNN._.1" -a "my-server-name\IIS APPPOOL\App4"  
"C:\path\winhttpcertcfg" -g -c LOCAL_MACHINE\MY -s "WS10012NNN._.1" -a "my-server-name\IIS APPPOOL\App5"  

如果您对该证书再次执行“-i”命令,您所有的授权都将失效,您必须重做。所以基本上,一个安装命令,然后你所有的授权都指向那个安装。如果您再次安装该证书,则必须再次授予所有内容。