Saturday, August 7, 2010

Using HTTPS for WCF in Windows Service

These are instructions on how to use HTTPS in a Windows Service application hosting a WCF web service. The steps are a consolidation of information provided by Microsoft at:
http://msdn.microsoft.com/en-us/library/ms733791.aspx

I've tried to keep this as simple as possible.
  1. Set the endpoint of your application to HTTPS (i.e. your app.config file). Note that if you are going to use a root certificate that is for your COMPUTER, your endpoint will need to match your computer name…not “localhost”. Example:
    https://mycomputername:9010/mywebservice
  2. Verify HTTPS is not already configured by viewing ports configured for HTTPS (admin privs required):
    C:> netsh http show sslcert
  3. Generate an application guid; any guid will do. This can be done from a computer with Visual Studio tools installed. Example:
    C:> uuidgen
    429d0213-340b-44db-991e-1c0c1ed3d91f
  4. Find the thumbprint value for a machine/computer certificate in Personal store on local machine. Remove the spaces from the thumbprint. Example:
    b41dad508c2025eabe10f7d88b2c9a66983f950d
  5. Register the certificate for whatever port you want (any IP address=0.0.0.0), using the thumbprint and guid (admin privs):
    C:> netsh http add sslcert ipport=0.0.0.0:9010 certhash=b51dad508c2025eabe10f7d88b2c9a66983f950d appid={429d0213-340b-44db-991e-1c0c1ed3d91f}
  6. Verify the port is configured for HTTPS (admin privs):
    C:> netsh http show sslcert
  7. To remove HTTPS for a port use the following:
    C:> Netsh http delete sslcert ipport=0.0.0.0:9010

No comments:

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...