The SignCode macro is dependent on the signcode.exe utility included with the .NET Framework SDK. Full information on the utility is found in the MSDN article, "File Signing Tool (Signcode.exe)" <link to http://msdn.microsoft.com/library/en-us/cptools/html/cpgrfFileSigningToolSigncodeexe.asp> . The .NET Framework SDK is installed by default when you install Visual Studio .NET. However, if you chose not to install the .NET Framework SDK, the macro will not function. If you have moved the signcode.exe utility to a different location, be sure the directory is included in your local path environment variable.
Signing an InfoPath project requires a code signing certificate file (.cer). A code signing certificate can be obtained from a certificate authority such as Verisign or from an internal corporate certificate authority. For debug and test purposes, a code signing certificate can also be created using the makecert.exe utility included in the .NET Framework SDK. A certificate created using makecert.exe is not suitable for publishing signed forms but will work fine for debugging and testing on a developer's computer.
To create a certificate with the makecert.exe utility, first a trusted root certificate authority must be created.
- Open the Command Prompt, type the following, and then press ENTER:
makecert -n "CN=TrustedRootCA" -r -cy authority -a sha1 -sky signature -m 1 -sv certRoot.pvk certRoot.cer -ss ROOT
- The Create Private Key Password dialog box is displayed. Click None.
- A Security Warning message is displayed stating "You are about to install a certificate from a certification authority (CA) claiming to represent: TrustedRootCA". Click Yes to install the certificate to the Trusted Root Certification Authorities store.
- To create a certificate used for signing, type the following, and then press ENTER:
makecert -n "CN=TestCert" -cy end -a sha1 -sky signature -m 1 -iv Certroot.pvk -ic certroot.cer -ss MY -sv MyKey.pvk MyCertificate.cer
- The Create Private Key Password dialog box is displayed. Because this is just a debug and test certificate, it is recommended that you use a blank password to make the signing process simpler. To do that, click None.
- The files MyCertificate.cer and MyKey.pvk are created in the directory where you issued the command in step 4. Copy them to the project directory of any InfoPath project you wish to sign.
Important The certificate created with this procedure is only suitable for testing and debugging. Be sure to obtain a legitimate code signing certificate from a certificate authority if you need to sign any release versions of your project. Additional information on the code signing process can be found in the MSDN article, "Signing and Checking Code with Authenticode" <link to http://msdn.microsoft.com/workshop/security/authcode/signing.asp> .
The SignCode macro is configured to run when a build of a project is successfully completed. Once you've copied your certificate and key file to your project directory, your project will be automatically signed when it is built. The SignCode macro is hard coded to look for certificate and private key files named MyCertificate.cer and MyKey.pvk located in the current project directory. To sign your project with a legitimate code signing certificate's files, you can either rename the files to these names, or can modify the CertificateFileName and KeyFileName constants
Macro Code Walkthroughs