TruePersona are authorised resellers of DigiCert, Thawte, GlobalSign, GeoTrust and Rapid SSL products

Banner
How to Sign Code PDF Print E-mail
Written by Chris Stone   
Wednesday, 11 October 2006 22:13

How to Sign

When you sign your file you actually add a small packet of information (1-4 KB) to the end of the file. When the browser downloads the file it reads this packet and contacts a CA (Certificate Authority) like verisign.com, tawthe.com and others... to verify with them the authenticity of the file.

Getting started

How to get started with code signing?

The current set of tools were released with the introduction of Microsoft Visual Studio 2005.

The tools are provided as part of the Visual Studio 2005 and in the Platform SDK. To download the Platform SDK, visit the following Microsoft Web site: http://msdn.microsoft.com

After you install the SDK you will have the code signing files on your PC:

The following files are of interest to us:

  • signtool.exe
  • makecert.exe
  • cert2spc.exe
  • pvk2pfx.exe

All the above tools are actually small console programs that should be run from a command prompt. When run, each program expects command-line parameters in a special syntax. 

Public Certificate

Where to get a Public Certificate?

To be able to sign your code you will need a certificate. Certificates are issued by Certificate Authorities (CA). There are many Certificate Authorities, you can get a full list of CAs by going to: Microsoft Root Certificate Program Members . TruePersona™ can supply code signing certificates recognised by the major CA's.

Acquiring a certificate from TruePersona™ is an easy and straight forward process. You provide sufficient information to enable TruePersona™ to identify you or your organization and then a certificate is issued.

If you do not want to go to the expense of buying a public certificate, you can begin with a test certificate. The test certificate can be used to sign your program in a test run. A program signed with a test certificate should not be distributed on the net.

Test Certificate

How to create a Test Certificate?

The following command line may be used to create a Test Certificate (CER) file:

 

makecert.exe -sv persona.pvk -n "CN=TruePersona Ltd." persona.cer

 

At the end of this process you will have the following 2 files:
  • persona.pvk - a "Private Key" file needed to create the certificate.
  • persona.cer - a "Public Key" file needed to create the certificate.

When running - "makecert.exe" will present the following dialog:

You should enter a password to protect your "Private Key".

Create Software Publishing Certificate

How to create a Software Publishing Certificate?

The "Software Publishing Certificate" (*.SPC file) is created from the "Public Key" file (*.CER) you created in the previous step.

The following command is used to create the "Software Publishing Certificate" (SPC) file:

 

cert2spc.exe persona.cer persona.spc

 

At the end of this process you will have one new file:
  • persona.spc - a "Software Publishing Certificate" file.

When running - "cert2spc.exe" will present the following dialog:

Enter here the same password you used when creating the "Test Certificate" or the "Public Certificate".

Purchase Software Publishing Certificate

How to purchase a Software Publishing Certificate?

You can purchase a certificate from TruePersona.

TruePersona can create the certificate for you or you can create your own through the website link provided by us. When you click the [Buy] button, you will go through a process that includes the following steps:

  • Enter your personal and company details.
  • Pay for the certificate.
  • Run a special applet that will create a Private Key file (*.PVK) on you computer.

During the creation of the Private Key file you will be prompted for a password. You should remember this password so that you can use it later when you sign your application. You must also copy the Private Key file to a safe place.

When creating the Private Key file on your computer, the applet will also create the corrsponding "Public Key" file.

It is then necessary to verify and approve your organization and domain. This process usually take few days. During this time you may be approached by telephone or other means and requested for means of identification.

When the verification process is concluded you will receive a link to a Certificate File (*.SPC). Download this file and do the following:

  • Copy the *.PVK file and the *.SPC file to a common directory.
  • Rename both files so that they have the same name (but different extensions).
The procedure described above may vary in details from one CA to another.

Personal Information Exchange

How to create a Personal Information Exchange file?

The following command line may be used to create a "Personal Information Exchange" (PFX) file:

 

pvk2pfx -pvk persona.pvk -pi Pass1 -spc persona.spc -pfx persona.pfx -po Pass2 -f

 

At the end of this process you will have one new file:
  • persona.pfx - a "Personal Information Exchange" file.
The program "pvk2pfx.exe" expects 2 passwords: Pass1 & Pass2:
Pass1: - Provide the same password you used when creating the Private & Public keys.
Pass2: - Provide a new password to protect the PFX file.

   * For security reasons it is recommended that Pass2 will be different then Pass1.

Sign Your Code

How to sign your code?

You can use signtool.exe to sign your code. 

The following commands may be used to sign your code.

 

set File = true.exe

set TimeURL = http://timestamp.verisign.com/scripts/timstamp.dll

signtool.exe sign /f persona.pfx /p Pass2 /v "%File%" /t %TimeURL%

 

At the end of this process the program file "true.exe" in this example will be signed.

As can be seen, this command expects the following parameters:

persona.pfx:The Personal Information Exchange file.
Pass2:Enter here the second password you used when creating the PFX file
File:The file name of the executable you want to sign.
TimeURL:The URL of a time stamping service provided for free by verisign.com.

Verify your Digital Signature

How to verify your digital signature?

This can be accomplished using signtool.exe.

The following commands may be used to verify your digital signature.

 

set File=true.exe signtool.exe verify /v /a "%File%"

 

As can be seen, this command expects only one parameter the name of the file under test.

Verify using Properties

You can also use the following method to verify your digital signature:
  • Open Explorer.
  • Browse to the file you just signed.
  • Right Click the file name and select "Properties".

Explorer will present you with the properties dialog of the file.
This properties dialog will include a new tab "Digital Signatures".
You can now read the details of the signature in this tab.

Further Information

Use the following links to learn more about Code Signing and Authenticode

Last Updated on Monday, 22 December 2008 23:12
 
SSL Certificate Partnerships
Copyright © 2010 TruePersona. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.

Who's Online

We have 1 guest online