Monday, August 16, 2010

Setting up HTTPS for local development without installing IIS

As the subject implies, I wanted to do some web development that used HTTPS. The WebDev.WebServer (aka Cassini) that comes with Visual Studio does not support HTTPS. I did not want to require IIS for myself or my colleagues.

I'm not entirely sure of all the details, but this seemed to work:

  • Create a test certificate as described here. You must run as an Administrator.

    > makecert -ss My -sr LocalMachine -sky exchange -r -n "CN=Wallace Kelly" -sk WallaceKelly -pe
    
  • Get the new certificate's "thumbnail" as described here. I used the MMC snap in.
  • Configure a port with the SSL certificate, as described here. The special IP address 0.0.0.0 matches any IP address for the local machine. The certhash is the "thumbnail" without the spaces. The appid is a GUID. I used the GUID for the WebServer2, from the AssemblyInfo.cs. I'm not sure if this can be any GUID.

    > netsh http add sslcert ipport=0.0.0.0:8080 certhash=4dbcbe2656f62af17ceba1f760
    ba7d065fd919bf appid={D7A0778F-A61C-463F-8C39-893DF0AA3748}
    
    SSL Certificate successfully added
    
    
    > netsh http show sslcert
    
    SSL Certificate bindings:
    -------------------------
    
        IP:port                 : 0.0.0.0:8080
        Certificate Hash        : 4dbcbe2656f62af17ceba1f760ba7d065fd919bf
        Application ID          : {d7a0778f-a61c-463f-8c39-893df0aa3748}
        Certificate Store Name  : (null)
        Verify Client Certificate Revocation    : Enabled
        Verify Revocation Using Cached Client Certificate Only    : Disabled
        Usage Check    : Enabled
        Revocation Freshness Time : 0
        URL Retrieval Timeout   : 0
        Ctl Identifier          : (null)
        Ctl Store Name          : (null)
        DS Mapper Usage    : Disabled
        Negotiate Client Certificate    : Disabled
    
    
    
    
  • Use WebDev.WebServer2, found here.

    > WebDev.WebServer2.exe /path:"c:\temp" /prefix:"http://localhost" /port:8080
    

No comments:

Post a Comment