Forum archive
Advice on updating the ASP .net on Apache appliance
I have been evaluating Mono by using the ASP .net on Apache appliance, which has yielded a few exciting discoveries in the world of open source .NET.
So far I have been successful in running "classic" ASP .net applications and MVC ASP .net applications (If you need some pointers on how to do so, you can read more in this other forum post). Now I have started to dabble in self-hosted applications using Owin and that's where I found that if you want to be able to run self-hosted applications which use https, you need to download the source code of mono, update it, compile it and install it (at least until this pull-request gets approved, then you should be able to get the latest deployment of mono and then the question would be how to just "upgrade" to that newer version of mono).
The last bit sounds scarier than it actually is. Here is how you do it with 14.1:
# Patch Mono 4.2.3.4 (Which is the version included in the appliance): # http://www.mono-project.com/docs/compiling-mono/linux/ # http://stackoverflow.com/questions/25171536/mono-httplistener-client-certificate/36721463 apt-get install patch -y # needed to patch automatically (optional if you update the file manually) apt-get install git autoconf libtool automake build-essential mono-devel gettext libtool-bin -y # needed to build wget http://download.mono-project.com/sources/mono/mono-4.2.3.4.tar.bz2 echo -e -n "83c83\n< \t\t\t\tSslServerStream ssl_stream = new SslServerStream (new NetworkStream (sock, false), cert, false, true, false);\n---\n> \t\t\t\tSslServerStream ssl_stream = new SslServerStream (new NetworkStream (sock, false), cert, false, false, false);\n" > nocerts.diff tar -xjf mono-4.2.3.4.tar.bz2 cd mono-4.2.3.4 patch ./mcs/class/System/System.Net/HttpConnection.cs ../nocerts.diff ./autogen.sh --prefix/usr # instead of /.configure make make install
And here is how you can register the existing TKL certificate to be used on Mono (Remember to never use the provided TKL certificate in a production environment, the following is an example on how to register an existing certificate):
- Create a p12 certificate from the existing TKL certificate (Replace the asterisks with a password, remember this password since you will use it in the next step):
# Make certificate for TurnKey Linux:
openssl pkcs12 -export -in /etc/ssl/private/cert.pem -inkey /etc/ssl/private/cert.pem -out cert.p12 -passout pass:********
- Register the p12 certificate (Replace the asterisks with the password you just specified and 443 the port number with your port number):
httpcfg -add -port 443 -p12 cert.p12 -pwd ********
So, now you are all set and you should be able to run a self-hosted application that listens to https. However, here come a few questions and the reason why this is a post in the support forum:
- How do you "clean up" your appliance from all the tools you had to install on it to compile Mono with your own modifications? (I mean, other than the obvious rm -R mono-4.2.3.4 and rm mono-4.2.3.4.tar.bz2 to delete the files used for the compilation)
- Is there a way to just get the mono run-time from your "development appliance" to a "production appliance"?
- How would you package an appliance that had nothing except for a trimmed-down version of mono which would allow you to run self-hosted applications?
- How would you "upgrade" to a newer stable version of Mono from the appliance?
(Please note I didn't specify how to build a self-hosted application since there is material around the internet on how to do that, but if you want an example I can post one)
Regards!
You are probably right, I recall saying something like that. Sorry my posI was probably a bit pedantic. Apologies on that.
A CA signed cert definitely gives a better (public) user experience and remains the best option for a pretty secure connection between unknown parties. I haven't used them myself (I have no need), but I see no reason not to use Let's Encrypt. Actually we are planning to provide an easy way to get Let's Encrypt SSL certs on TurnKey for v14.2.
If you are communicating between known parties then a well constructed self signed cert is almost certainly more secure. The parties must already have trust though (e.g. shared the cert via PGP encrypted email or a local CA). If you were to use a self signed cert purely for security though, you probably wouldn't want to use the default TurnKey cert either!
Regarding the CN in the self signed cert, I have no idea about that. If we can get that working OOTB without any security implications I'm in! I'm assuming turnkey-make-ssl-cert will need tweaking?!
Re comment about the cert.pem being overwritten. The original blog post is 2010 and pre-dates the above script. The comment is valid in context of the original blog post, but should be irrelevant to TurnKe,y at least as of v14.0+. TurnKey now saves it's certs in /etc/ssl/private.
Re CA appliance, yeah I think that'd be a great one. I think Ken has added that to his "possibles" shortlist for when he gets some time free from work.
Ahh, thanks for your explanation of "trimmed down mono appliance". I love your vision. It sounds awesome! For our next major release (v15.x) we are planning on moving to a container format which we have dubbed TKLX. It would really lend itself to what you're talking about. It'd be a lot trickier with the current monolithic builds.
I certainly see the appeal of an asp.net nginx appliance. But with our current builds, every appliance we add adds overhead. That's one of the reasons why almost everything that is primarily a web server uses Apache. Apache is not the fastest or most resource friendly web server. But it is flexible, powerful, well documented and almost uniformly supported by third party software. So basically IMO we chose the best all rounder not necessarily the best for each use case.
Having said that, I'm always happy to hear arguments for and against different ideas. So keep em coming! :)