Tyler Forsythe
Tyler Forsythe

Reputation: 1551

Grant Multiple IIS App Pools Permission to Same Certificate Using winhttpcertcfg

I have a certificate I need to install and grant access to for my IIS C# .NET applications to securely connect to FirstData. I don't know much about certificates, so I'm running commands that look like this:

"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"  

However, this doesn't seem to work as expected. I actually ended up doing the above for 3 of the app pools, and then later doing it for 2 more. Some of my sites don't work, but if I rerun just the command for one site, it breaks the others. It seems like I can't get all 5 to work at the same time.

It seems like the proper sequence should actually be one -i command, and then 5 -g commands. But I'm not sure, and I can't find any multi-site examples online. How do I correctly grant all 5 of my app pools permission to use the certificate?

Upvotes: -1

Views: 295

Answers (1)

Tyler Forsythe
Tyler Forsythe

Reputation: 1551

While I still do not fully understand the ins and outs of winhttpcertcfg and its switches, I was able to solve my problem. The answer is to do ONE -i command and then the all the -g commands. Like so:

"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"  

If you execute an "-i" command again for this certificate, all of your grants will become void and you have to redo them. So basically, one install command, then all of your grants point to that install. If you do another install of that certificate, you have to grant everything again.

Upvotes: 0

Related Questions