Certificates in Wix

Here's another of the nice stories when I try to make somthing work and it's just really hard to find any documentation about it.

So I have this installer (a .wxs file) which had some hacky way to install certificates (executing custom actions and calling an external application that would register them). The external app would exist as a binary key in the .wxs and be called during the installsequence. It was quite messy and I though a long time on how to clean this up.

One of these days I had a couple of hours to spare (which is not so usual) and I started to look over on how I could cleanup this code. So I found out about the Certificate node in Wix. Here's the link to the documentation: http://wix.sourceforge.net/manual-wix2/wix_xsd_certificate.htm

This way all the ugly code that I had was changed in just 3 lines:

<Component Id='CPNT_CERTS' Guid='$(var.GUID_CPNT_CERTIFICATES)' DiskId='1'>
<Certificate Id='CERT' StoreLocation='localMachine' Name='certname' StoreName='personal' CertificatePath='certpath' PFXPassword='password'/>
<Certificate Id='ROOTCA' StoreLocation='localMachine' Name='Cert Root CA' StoreName='root' CertificatePath='rootca path'/>
<Certificate Id='SUBCA' StoreLocation='localMachine' Name='Cert Sub CA' StoreName='ca' CertificatePath='subca path'/>
</Component>

And here's the part that will executes the certificate during the install

<InstallExecuteSequence>
.....
<InstallCertificates>NOT Installed</InstallCertificates>
.....
</InstallExecuteSequence>

Hopefully this helps, it was really hard for me to find any documeentation or help on how to use the certificate node.

As always, please let me know if this helps or if I missed somthing.

Thanks,
Ionutz