Signing Code Using PVK and SPC Files

Posted on August 28, 2008 at 11:26

I have a Windows Forms application that is ready for distribution. One of the last steps is getting code-signing working. We purchased a Code Signing certificate from Thawte. This resulted in a PVK (private key) and an SPC (certificate) file being delivered. Then the question arose of how to go about using them.

Referring to the documentation for SignTool.exe, there did not seem to be a way to sign the code using the PVK and SPC files via the command line. Though this was possible using the GUI program (accessible using the -signwizard command line option), in order to get this integrated with my build process, I needed a way to initiate the code signing fully from the command line.

The solution turned out to be the following:

1) Convert the PVK and SPC files to a PFX file (Personal Information Exchange file – this encapsulates the info found in the PVK and SPC files). This is done using the pvk2pfx.exe executable (which had been included as part of the .Net SDK, and was found in C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin on my computer). I used the following syntax to do this (Pass1 is the original password for the PVK file, Pass2 is the new password for the pfx file. Ref):

pvk2pfx.exe -pvk mykey.pvk -pi Pass1 -spc mycert.spc -pfx newpfxfile.pfx -po Pass2 -f

After this ran, I now had a PFX file called newpfxfile.pfx ready to be used.

2) Use SignTool and the PFX file to sign my code. Now that I had a PFX file, I was able to sign my code (and timestamp it) using the following command line syntax:

signtool.exe sign /f newpfxfile.pfx /p Pass2 /d "AppDescription" /du "AppURL" /t http://timestamp.verisign.com/scripts/timstamp.dll LocationOfCode

Seems simple, but it took quite a lot of research to get this process right. Hopefully the info can help save someone else some time.



Memory Profiler Eating Up My Memory

Posted on August 26, 2008 at 22:01

I have a Windows Forms app that has a very long and complicated initialization process. As the release is approaching, today was my day to try and shoft things around in the init, get it loading faster. So on recommendation from a few sources, I downloaded a profiler – Jet Brains dotTrace. Install and first profile went well. However, as I started to make more changes and run more profiles, I noticed that there were no improvements in initialization time. If anything, things were getting worse. Task Manager helped pinpoint the culprit:

If the numbers are too small, that is 1,241,596 KB. Yikes. Compare that with the second and third-place contestants, FireFox 3 at 174,584 KB, Visual Studio 2005 at 144,940 KB.

This is what happened after I closed the profiler (see if you can guess when that happened):

And I thought that Firefox 2 was using a lot of memory. I know that these programs are complicated, but I find it hard to comprehend how a program is supposed to help you track the memory usage of the applications that you are debugging when it ends up gobbling down over 1.2GB of RAM all by itself and making the computer basically unusable.



Ajax Progress Image Generator

Posted on at 14:32

I was in need of an Ajax-style animated gif that could be used to indicate that something is going on in the background or loading. I have seen them on hundreds of sites, but I don’t feel comfortable just copying someone else’s image to use for myself.

After a bit of searching, I found this site: AjaxLoad.Info. This is a nice, simple site that generates 37 different “loading” animated gifs, allowing you to customize the style, foreground and background colors, and transparency. Definitely a good site to know about.



Four Tips for Handling Distractions when Working from Home

Posted on August 15, 2008 at 12:43

Working from home has lots of benefits: no commute, you don’t have to dress for the office, play your music loud, etc. However, in order to keep up (and improve on) your productivity while working at home, it is essential to come up with and enact a strategy for dealing with distractions.

Read the rest of this entry »



Using SyntaxHighlighter to Format Code in WordPress

Posted on August 14, 2008 at 10:04

Based on a question in the StackOverflow beta site, I did some quick research into what are the best ways to perform syntax highlighting on code that is posted on blogs. Among the methods that were suggested (by myself or others):

  1. Hack together your own display logic to format it as you see fit
  2. Use the SyntaxHighlighter JavaScript library
  3. Use Windows Live Writer with the Insert Code plugin (I discuss that here)
  4. For WordPress, use the WP-Syntax plugin

Coincidentally, I had heard Scott Hanselman talking about how he does code formatting just a couple of days ago, in Hanselminutes #125, where he described how he posted code on his blog by putting it inside <pre></pre> tags, adding specific name and class attributes, and letting some JavaScript library do the formatting work. So I went to his blog, opened up a post with some code, and found my way to the SyntaxHighlighter JavaScript library. This is a very nifty library that handles formatting very nicely for a number of popular programming and scripting languages, and seemed to have a very easy implementation. So I decided to implement it for formatting code on my site.

Read the rest of this entry »



My Developer Applications and Utilities List

Posted on August 12, 2008 at 12:21

I am getting ready to move over to a new laptop, so I think that now is a good time to record (both for myself and for anyone else who may find this useful) the list of all the different programs and utilities that I have installed on my computer that I find useful (or necessary) enough to reinstall on the new box.

Read the rest of this entry »