You are here
Jeff Wilson - Thu, 2020/06/18 - 18:42
Hi, are there any docs that I can follow that will help me replace the reverse proxy nginx self signed cert in an app appliance like (the new) mattermost? I've looked and I can't find anything. Any helpful direction would be very appreciated!
Thanks!
Forum:
Tags:
Hi Jeff, depends on what you're wanting to do?!
First up, it's probably being aware that TurnKey is based on Debian, so often instructions that apply to Debian should apply to TurnKey as well. However, in the case of SSL certs that's not quite the case as we do tweak things a bit there.
The default certificate that all SSL TurnKey services use (e.g. webservers, Webshell & Webmin) can be found at /etc/ssl/private/cert.pem (and the key at /etc/ssl/private/cert.key). They are put together is a very specific way so that they work with all the different services that may use the same certs.
If you wish to use free Let's Encrypt certificates, then Confconsole has a Let's Encrypt plugin that can do that for you. That will replace the default certs that I noted above and the same cert should work with all HTTPS endpoints on your server. Note that it will only work if your domain already resolves to your server IP and port 80 needs to be publicly accessible. It's perhaps also worth noting, that this should "just work" in v16.0+ appliances, but older v15.x appliances have a number of issues. There are fixes for the issues, but you are advised to use the v16.0 appliance if possible.
Alternatively, if you have a thrid party cert that you'd like to use, so long as they are the correct format and you put them together the same as the default ones, you can replace those and all the services should leverage the updated cert and SSL should "just work" without browser warnings.
However, if you have third party certs and are in a rush and just want to replace the certificate (and key) for Nginx then that's possible too. You can put your third party certificates wherever you want (although /etc/ssl/private is a good place IMO) and then update the paths in /etc/nginx/include/ssl by default they are:
I hope that helps...
It looks like the key section is encrypted with a password.
TBH, it's not something that I'm super familiar with. Without having a real key to play with, I'm really just relying on my limited understanding, combined with the online resources that I've checked up on. So it's pretty much the blind leading the blind here, but let's see how we go...
First up, it appears that the private key part appears to be encrypted. And according to the output you've posted, it also has a password. Note where the Nginx log says "Enter PEM pass phrase:".
Also, I'm not 100% sure, but a bit of reading that I've done suggests that your key might be in a legacy format that may or may not work with Nginx and/or Stunnel (Webmin/Webshell are behind Stunnel). I'm judging that by the "BEGIN RSA PRIVATE KEY/END RSA PRIVATE KEY" text. It may be fine, but if not, you may need to convert it to a "pkcs#8" format key (which will have have the text "BEGIN PRIVATE KEY/END PRIVATE KEY" text instead).
It's also worth noting that Nginx requires the key section to be in a separate file. If you want to use the same cert/key with Stunnel (Webmin/Webshell) too, then IIRC you'll want them altogether in the cert file, plus just the key section in the key file. That way Nginx will ignore the key section in the cert file and read it from the key file and Stunnel will read both the key (and the cert) from the cert file. I.e. have your files like this:
So just considering Nginx and the password protected key, you essentially have 3 options, either way you'll need the password:
If you choose option 1 or 2 above; there is a chance that you may not need to do anything more (than the appropriate action required by each action). If you want to follow option 3, then OpenSSL should be able to do what is required. You may be able to pass the file that you have into OpenSSL, although I suspect that you will need to copy out the "RSA PRIVATE KEY" section, i.e. these lines:
(And all the lines of random characters that form the key between these)
From what you've posted, assuming that the filename is cert.pem and the file(s) are in /path/to/where/your/keys/are; this should do the trick to separate the bulk of the file from the key:
That will leave you with the original file(s), plus two new files; enc.key & new.cert. To decrypt the key file, removing the password and converting to pkcs8 format (just in case), this should do the trick:
You will be asked for the password interactively, so you'll need to enter it when asked. Alternatively, you could include it in the command, via the "-passin" switch, like this (assuming that your password is MY_PASS).
Double check that the new key file (dec.key) no longer includes the note about encryption with cat. I.e.:
Then assuming that you want them bundled back together and rename them to the default names; do this:
And if I've read everything correctly (fingers crossed), you should now be all good now... :)
If not, please let me know which step causes issues and the exact error message/messages you get.
Add new comment