I have a Windows Forms application installed using InnoSetup that my users download from my website. They install this software onto multiple PCs.
The application talks to a Web API which must be able to identify the user. I am creating a web application where the user can log in and download the app. I would like to embed a universally unique ID into the installer so that they do not have to login again after installation. I want them to download and run setup.exe, and have the application take care of itself.
I am considering a couple of options:
- Embed a user-specific UUID into setup.exe and perform code-signing on-demand on the web server
Downside: not sure how to do this? - Embed a user-specific UUID into the name of the installer file (e.g. setup_08adfb12_2712_4f1e_8630_e202da352657.exe)
Downside: this is not pretty and would fail if the installer is renamed - Wrap the installer and a settings file containing the UUID into a self-extracting zip
How can I embed user-specific data into a signed executable on the web server?
The entire PE is not signed. You can embed data into a signed PE by adding it to the signature table. This method is used by Webex and other tools to provide the one-click meeting utilities.
Technically, the PKCS#7 signature has a list of attributes that are specifically designated as unauthenticated which could be used, but I know of no easy way to write to these fields without a full PE parser. Luckily, we already have
signtool
, and adding an additional signature to an already signed file is a non-destructive operation that uses the unauthenticated fields.I put together a demo which uses this technique to pass data from an MVC website to a downloadable windows forms executable.
The procedure is to:
(must be able to run without dependencies - ILMerge or similar)
signtool
to add the auxiliary signature to the temp fileOn the client side, the app:
The process has a number of advantages:
Usage
Client side retrieval of data (Demo Application\MainForm.cs)
Server side stamping (Demo Website\Controllers\HomeController.cs)