Welcome to EMC Consulting Blogs Sign in | Join | Help

Stuart Preston's Blog

Stuart was CTO for Application Consulting EMEA at EMC Consulting until October 2009, now blogging at http://stuartpreston.net

Automating signtool.exe (or how to make a PFX file from a PVK and SPC file!)

It is often desirable to automate the process of using signtool.exe to digitally sign compatible files (for example .cab, .msi, .exe, .dll, .ocx) for distribution. 

If you signed up with a certificate provider such as Verisign and went through the somewhat tedious but necessary verification exercise, you'll probably have found yourself left at the end of things with a private key (extension .pvk) and a set of certificates they supplied (extension .spc).

Rather than having to import these certificates into the local store on each machine you need to do a build on, signtool.exe can work with a single PFX file which is a complete certificate store (including the private key).

To create the PFX file, all you need is the PVKIMPRT.exe tool which you can download from here: http://www.microsoft.com/downloads/details.aspx?FamilyID=F9992C94-B129-46BC-B240-414BDFF679A7&displaylang=EN

Simply run the tool as follows:

pvkimprt.exe -pfx <yourspc.spc> <yourpvk.pvk>

A dialog will popup asking for the password to the private key, and finally lets you select the output filename.

You are now ready to use signtool.exe at the command line with the "sign" switch (instead of "signwizard").  Assuming you want to digitally sign and timestamp MyInstaller.msi with MyPfxFile.pfx, the command line would be something like this:

signtool.exe sign /f MyPfxFile.pfx /p MyPrivateKeyPassword /d "My Product Name" /du "http://www.myproducturl.com" /t "http://timestamp.verisign.com/scripts/timestamp.dll" "MyInstaller.msi"
  

Published 19 February 2007 08:13 by Stuart.Preston

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

TrackBack said:

May 14, 2007 17:59
 

TrackBack said:

May 14, 2007 17:59
 

Husker said:

you can also use pvk2pfx.exe instead if pfximprt.exe http://msdn2.microsoft.com/en-us/library/bb172338.aspx
June 20, 2007 12:58

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

I have now left EMC Consulting and can be found at http://stuartpreston.net
Powered by Community Server (Personal Edition), by Telligent Systems