The .NET HttpListener class allows you to configure a prefix such as:
https://+:8080
meaning that the HttpListener listens on the any address 0.0.0.0
and port 8080
over HTTPs instead of HTTP. On Windows, using HTTPs for HttpListener requires an additional setup of certificates and this tutorial is about accomplishing the same on Unix.
Certificates can be created using the openssl
command.
First, create a key file:
openssl genrsa -des3 -out Corrade.pem
preferably, you should not enter any password, or remove it with:
openssl rsa -in Corrade.pem -out Corrade.nopass mv Corrade.nopass Corrade.pem
then create a sign request:
openssl req -new -key Corrade.pem -out Corrade.csr
The key file, Corrade.pem
must be converted to Windows format using pvktool. To do that, issue the command:
openssl rsa -in Corrade.pem -outform PVK -out Corrade.pvk -pvk-none
The final step is to register the certificate with mono's httpcfg
. For example, in case you have a HTTP prefix such as:
https://+:8080
then you would issue:
httpcfg -add -port 8080 -pvk Corrade.pvk -cert Corrade.crt
After the certificate is installed, you can start using the HTTPs prefix.