6 minutes to read read

By the end of First project we already have a WebApi Self Hosted in Windows Service, but on HTTP. In this post i shall try to add a SSL layer over the top if it to provide additional transport layer security. Things are much easier with IIS, which provides default and simple settings and configurations for all settings like SSL or others.But moving things out of there can be a little tricky. Also, in this post, we shall not be using the developer certificate generated by the IIS, but an actual one issue by CA. For this we shall first register an CA Certificate and then SSL. So let’s roll.

The Tools

We shall be using the following tools provided by Microsoft that can be accessed from developer command line tools.

  • makecert
  • pvk2pfx
  • netsh (provided by windows)

PS: If you can get a proper SSL Certificate from a commercial CA, you can directly move here.

Creating the CA

All the certificates are issue by Certifying Authority or a CA. So for creating an CA, fire up the “Visual Studio Command Line Tools” and run as administrator. I would recommend create a new folder and browse to that so that things dont mix up.

Type in the following command to generate a new CA certificate.

Continue reading

Services

4 minutes to read readWith the introduction of OWIN  and self hosting, microsoft has really opened a lot of possible doors for developers and application users. This post is targetted to have an OWIN application hosted in Windows Service. Also we would be configuring the SSL for the Site.

Source code can be accessed at: GitHub

Creating a Windows Services Project

This is pretty straightforward. In visual Studio, Create new project and select Windows Service as project. This will add a project with default Service “Service1”. Rename to whatever the name expected.

Add OwinSelfHost and WebApi2

In the Tools-> Nuget package Manager -> PM console type in the following command to get the WebApi and self host packages referenced.

Install-Package Microsoft.Aspnet.WebApi.OwinSelfHost

This will install and reference all the required packages and dependencies. Also we need one more package to debug and use some functions like welcome package. For this import the  Microsoft.Owin.Diagnostics using PM Console.

Install-Package Microsoft.Owin.Diagnostics

Also, to Enable Cross Origing Resource Sharing, we need to import the following package:

Install-Package Microsoft.Owin.Cors

At this point the we are Good to Start.

Continue reading