How to generate and install a signed *.inf file

To totally unlock this section you need to Log-in


How can we sign the INF file that we have already prepared so that it can be installed on a Windows 8/8.1/10 machine?

There are 4 distinct steps to follow before an INF can be installed onto a Windows system.

Generate a catalog (.cat) from the INF

This can be done by using the Inf2Cat tool that is provided by Microsoft via the Windows Driver Kit (WDK). This tool is typically installed at: C:\Program Files (x86)\Windows Kits\8.0\bin\x86 (for Windows 8 WDK package).

One of the parameters given to this tool is the list of OS’s the generated catalog will need to support. Since earlier versions of this tool don't accept the Windows 8 specific values, the WDK v8.0 (that supports Windows 8) is required. Be sure to navigate to the directory containing the Inf2Cat tool from the command prompt. Example syntax:

cd C:\Program Files (x86)\Windows Kits\8.0\bin\x86

Also, it is recommended to run the command prompt as an Administrator if possible.

Syntax: Inf2Cat /driver:<path> /os:<os1>[,<os2>]...

  • <path>: Path to the directory that contains the INF. The INF file must be in a directory (e.g. cannot be a stand-alone file in the C: drive). The INF already has the name of cat file to generate.
  • <osn>: The OS to support: e.g. 2000, XP_X86, Vista_X64, 7_X86, 8_X64, etc.
  • Output: If the contains an *.inf file, this command will create a corresponding *.cat file next to it.

Obtain or create a certificate that can be used to sign the *.cat

Ideally, you should contact a Certificate Authority (CA) to obtain a certificate that you can use to sign all your drivers and INF’s. A certificate typically has a pair of keys, public and private. The public key is distributed to clients who need to use the signed binary/INF.

The private key is only available to the owner of the certificate and is used to sign anything that needs to be signed. The private key should be protected and not distributed. The public key has enough information to verify the certificate owner.

This process has a few drawbacks:

  1. There is an annual fee that needs to be paid to the CA to obtain and use the certificate from them.
  2. If you aren’t distributing the INF to your customers and only need to use it on your own machine, this process is not feasible (unless you are buying the certificate for other reasons).

A workaround if you do not want to buy a certificate from a CA is for you to create a 'personal' certificate. This certificate, along with the private key, can be installed on a development machine where you will generate the *.cat file and sign it using that certificate.

Next, take the *.inf file, the signed *.cat file, and a copy of your public key (in the form of a certificate) to the deployment systems, where you will first install the public certificate as a 'trusted' certificate and then install any *.inf file that has a *.cat file signed with that certificate. These personal certificates (extension .pfx, in this case) can be generated using a variety of third party applications such as Adobe Reader, the Java SDK, and openssl for Linux distributions.

Sign the .cat using the certificate

Once the *.cat file is generated and the private certificate is installed on a development machine, the *.cat file can be signed using that certificate. Microsoft provides a tool to sign the INF’s, called SignTool. This tool should be available with the WDK. It is located in the same folder as the Inf2Cat tool: C:\Program Files (x86)\Windows Kits\8.0\bin\x86.

Please note that the WDK may require a certain version of Visual Studio to use the SignTool. This requirement will be listed on the WDK download page. This tool is also available from the Windows Platform SDK.

After installing the Windows 7 SDK, the tool will be located at: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin. To use SignTool, make sure to navigate to the directory containing the SignTool from the command prompt. Example syntax:

cd C:\Program Files (x86)\Windows Kits\8.0\bin\x86.

Syntax: signtool sign [options]

If the private/public key pair is in a file (in .pfx format):

signtool sign /f C:\mycertificate.pfx /p mypfxpassword c:\

If the key is installed on the development machine:

signtool sign /n mycertificatename C:\

Install the public certificate onto the target Windows 8 machine before installing the INF.

Once the *.cat file is signed with the private key, the *.inf file, the signed *.cat file and the public certificate can be distributed together. To install the *.inf file onto the machine the public certificate first needs to be installed.

If the certificate was obtained from a CA, it already has a trusted chain of certificates up to a 'Trusted Root CA'. Otherwise, if it is a personal certificate, it needs to be installed as a 'Trusted Root'.

To install, right click the public certificate (*.cer created by third party application) and choose Install Certificate. In the dialog that shows up, select Local Machine and press Next. In the following dialog, choose Place all certificates in the following store, press the Browse button and choose Trusted Root Certification Authorities from the list. Press OK to go back to the import wizard and press Next. Press Finish. Press OK when prompted with the confirmation dialog.

Note: To view the certificates installed on the system:

  • Run mmc command to launch the Microsoft Management Console
  • From the menu, choose File » Add/Remove Snap-in...
  • In the dialog, click on Certificates and press the Add button in the middle of the dialog.
  • In the dialog that shows up, choose the Computer account radio button and press Next and Finish.
  • Press OK.

In the MMC, now you can see the certificates installed for the current user. The certificate that was imported needs to be under Trusted Root Certification Authorities. If it is not, you can right click on the Certificates (Current User) and then choose to Find Certificates.... Once it is found, you can copy (or cut) and paste it under the Trusted Root Certification Authorities.