About Links Archives Search Feed Albums of Note

Enabling SSL Certificates On Any Given Port

Following on from my travails with HttpListeners not working as a non-admin user [/post/2008/07/28/Enabling-HttpListeners-for-Non-Admins.aspx], it turned out that the Cardspace samples (download them here [http://netfx3.com/files/folders/cardspace_samples/default.aspx] if you’re interested) had one more sticking point up their sleeve before everything worked. The main example demonstrates how a simple Security Token Service is used to verify the managed card a user wants to send to a site. However, the service is accessible only through the HTTPS protocol on port 7001 and Cardspace was unable to access it. A little digging revealed that the setup scripts for the sample tried and failed to build a copy of httpcfg, a utility found on Windows Server 2003. I didn’t have the necessary files to build httpcfg [http://technet2.microsoft.com/windowsserver/en/library/e17527d2-105a-451f-8e3f-d515479527011033.mspx?mfr=true] successfully, bit it turns out that the netsh [http://support.microsoft.com/kb/242468] utility that comes with Vista and helped me out previously [/post/2008/07/28/Enabling-HttpListeners-for-Non-Admins.aspx] could also help me out here to.

The command required to add the certificate to a port with netsh is

netsh http add sslcert ipport= certhash=thumbprint appid= arbitrary_guid

And the corresponding one to remove it is

netsh http delete sslcert ipport=


The add command needs two pieces of information besides the port number.

If you’ve never needed to find a certificate’s thumbprint before, hit Win+R and run certmgr.msc from the prompt to open the Vista Certificates MMC Viewer. (If the certificate is stored in the Local Machine certificate store rather than your own accounts store, you’ll need to run certmgr.msc as an admin). The certificate should be stored in Personal. When you find it, double-click it and select the Details tab. If you scroll the view down, you’ll see Thumbprint towards the bottom of the dialog.

You’ll need to copy all 20 pairs of hex digits and remove all the spaces. Given the example above then, you can add the certificate shown to port 7001 using this command.

netsh http add sslcert ipport= certhash=d47de657fa4902555902cb7f0edd2ba9b05debb8 appid={C61EC2E2-BC18-4522-903B-F44A56299787}

And then you can check that all’s well with this command

netsh http show sslcert

This will show you all the certificates bound to a port on your machine. netsh [http://support.microsoft.com/kb/242468] - the network admin’s swiss army knife

Posted on August 1, 2008   #Geek Stuff  

← Next post    ·    Previous post →