I've had some good feedback about the post, but also had a request for a working example (in order to illustrate how the code fragment is used in an Installer.wxs file).
I've cooked up a sample visual studio solution that installs a test certificate (generated using the MSDN makecert certificate example "makecert -sk XYZ -n "CN=XYZ Company" testXYZ.cer ").
You'll probably need to re-path references to the WixIISExtension and WixUIExtension in relation to your development environment but hopefully this should help you.
The previous post is the third most accessed post in my blog (which probably speaks as much for the number of people that read this as it does it's utility) so this should be useful to someone.
It's worth noting that this example installs the junk certificate as a Root CA so you might want to change that or ensure you remove it once you're done.