I decided to write a techie themed blog for once as this is my field of interest. Unusually for me I decided to make this a Windows article.
Driver signing in 64-bit Windows is a real pain. I’m unsure why Microsoft decided this would be a good idea unless their main aim was to further disadvantage people who create free software. Thanks to this driver signing requirement, if you write a Windows driver for some piece of hardware you either have to shell out several hundered of your hard-earned monies for an accepted code-signing certificate or expect people to run Windows in test-mode. This second option removes any advantage Microsoft may feel they introduced by adding the signing requirement.
I recently had to take a self signed MSI and put an accepted signature on it so the FlexiScale Windows images can load the drivers at boot time. Here’s how I did it.
- Download the MSI file and put it somewhere useful
- Install Windows Driver Kit from http://www.microsoft.com/whdc/devtools/wdk/wdkpkg.mspx
- Install Qwerty.Msi from http://www.qwerty-msi.com/
- In Qwerty.Msi go to File → Open and open the original MSI file. This will unpack the files to a folder called $FILENAME.Sources.
- Delete any exisiting “.cer” files
- Open a Windows Driver Kit shell (Start → All Programs → Windows Driver Kits → WDK 7600.16385.1 → Build Environments → Windows Vista and Windows Server 2008 → x64 Free Build Environment).
- In the driver kit shell create new catalog files with the inf2cat command (example below is for the Xen GPLPV drivers, your paths will vary)
cd c:\Users\iwatson\Downloads
inf2cat /os:Server2008_X64,Server2008R2_X64 ^
/driver:"gplpv_Vista2008x64_0.11.0.238.msi.Sources\SourceDir\PFiles\Xen PV Drivers\drivers\xennet"
inf2cat /os:Server2008_X64,Server2008R2_X64 ^
/driver:"gplpv_Vista2008x64_0.11.0.238.msi.Sources\SourceDir\PFiles\Xen PV Drivers\drivers\xenpci"
inf2cat /os:Server2008_X64,Server2008R2_X64 ^
/driver:"gplpv_Vista2008x64_0.11.0.238.msi.Sources\SourceDir\PFiles\Xen PV Drivers\drivers\xenscsi"
inf2cat /os:Server2008_X64,Server2008R2_X64 ^
/driver:"gplpv_Vista2008x64_0.11.0.238.msi.Sources\SourceDir\PFiles\Xen PV Drivers\drivers\xenusb"
inf2cat /os:Server2008_X64,Server2008R2_X64 ^
/driver:"gplpv_Vista2008x64_0.11.0.238.msi.Sources\SourceDir\PFiles\Xen PV Drivers\drivers\xenvbd"
- Because of some issue between Microsoft and Verisign’s Certificates you may need to follow the instructions at https://knowledge.verisign.com/support/ssl-certificates-support/index?page=content&id=SO16565&actp=search&viewlocale=en_US to add the alternative intermediate cert from Verisign.
- Download the Verisign cross-certificate from http://www.microsoft.com/whdc/driver/install/drvsign/crosscert.mspx. You need to remember where this unpacks as you need to supply the name as the /ac argument to signtool later.
- Get the SHA1 thumbprint of the key you want to use to sign the drivers.
- Start → mmc → File → Add/Remove Snap-in… → Certificates → Add → Finish → OK
- Go To Certificates – Current User → Personal → Certificates
- Double Click on certificate you want to use
- On Details tab scroll to bottom and click Thumbprint. This will display the hex you need for the /sha1 command line option below.
- Sign the catalog files
signtool sign /v /t http://timestamp.verisign.com/scripts/timestamp.dll ^ /sha1 $hex_string_from_sha1_section /ac "C:\Users\iwatson\Downloads\MSCV-VSClass3\MSCV-VSClass3.cer" ^ "gplpv_Vista2008x64_0.11.0.238.msi.Sources\SourceDir\PFiles\Xen PV Drivers\drivers\xennet\xennet.cat" signtool sign /v /t http://timestamp.verisign.com/scripts/timestamp.dll ^ /sha1 $hex_string_from_sha1_section /ac "C:\Users\iwatson\Downloads\MSCV-VSClass3\MSCV-VSClass3.cer" ^ "gplpv_Vista2008x64_0.11.0.238.msi.Sources\SourceDir\PFiles\Xen PV Drivers\drivers\xenpci\xenpci.cat" signtool sign /v /t http://timestamp.verisign.com/scripts/timestamp.dll ^ /sha1 $hex_string_from_sha1_section /ac "C:\Users\iwatson\Downloads\MSCV-VSClass3\MSCV-VSClass3.cer" ^ "gplpv_Vista2008x64_0.11.0.238.msi.Sources\SourceDir\PFiles\Xen PV Drivers\drivers\xenscsi\xenscsi.cat" signtool sign /v /t http://timestamp.verisign.com/scripts/timestamp.dll ^ /sha1 $hex_string_from_sha1_section /ac "C:\Users\iwatson\Downloads\MSCV-VSClass3\MSCV-VSClass3.cer" ^ "gplpv_Vista2008x64_0.11.0.238.msi.Sources\SourceDir\PFiles\Xen PV Drivers\drivers\xenusb\xenusb.cat" signtool sign /v /t http://timestamp.verisign.com/scripts/timestamp.dll ^ /sha1 $hex_string_from_sha1_section /ac "C:\Users\iwatson\Downloads\MSCV-VSClass3\MSCV-VSClass3.cer" ^ "gplpv_Vista2008x64_0.11.0.238.msi.Sources\SourceDir\PFiles\Xen PV Drivers\drivers\xenvbd\xenvbd.cat"
- Finally go to Project > Build.
This will build the new .msi file and save it in “$FILENAME.Sources\Debug\Disk1_1″
It is, of course, too much to hope this will cover all eventuallities in Windows driver signing. If you have been following this article to sign your own drivers then I hope it gets you close.
