Standard

Nice easy to follow article on implementing HTTPS with a self hosted app

Pedro Félix's shared memory

In a previous post, I showed how to  self-host ASP.NET Web API. This post shows how to change that example in order to enable HTTPS support.

  1. On an elevated console (“Run as administrator”), execute “netsh http add urlacl url=https://+:4443/ user=<your user name>”, to allow the running user to listen on port 4443 using HTTPS (note the use of ‘https’ instead of ‘http’ in the above command).
  2. Also on an elevated console, register the server certificate by running

    netsh http add sslcert ipport=0.0.0.0:port certhash=thumbprint appid={app-guid} where

    • port is the listening port (e.g. 4443); the special IP address 0.0.0.0 matches any IP address for the local machine;
    • thumbprint is the certificate’s SHA-1 hash, represented in hexadecimal;
    • app-guid is any GUID (e.g. {00000000-0000-0000-0000-000000000000}) , used to identity the owning application.
  3. In the previous post’sMain method, replace the HttpSelfHostConfiguration class…

View original post 48 more words

Advertisements

Servicestack, Self Hosting and SSL

Standard

I’ve been exploring http://servicestack.net recently and redesigning our systems architecture around REST principles.  It’s looking good, but a lot to learn!

Additionally the service that’s being developed will be self-hosted .NET (no IIS!) to help making  testing and automated deployment easier.

So gotchas I found already:

When setting up the apphost don’t forget the trailing slash – http://localhost:2013 won’t work http://localhost:2013/ will work!

If you want the service to listen on any host name then set the service up as http://*/ or you could add a port in http://*:2013/

If you want to do SSL then you need to read this article  http://blogs.msdn.com/b/jpsanders/archive/2009/09/29/walkthrough-using-httplistener-as-an-ssl-simple-server.aspx – I’m still working on it!