You may want to add an extra layer of your security to your app. After installing Rocket.Chat following our deploy-with-docker-and-docker-compose.md guide, here are the next steps to follow:
sudo apt install -y nginx
Install Certbot to manage SSL certificates from LetsEncrypt \
sudo snap install --classic certbot
sudo certbot --nginx
You’ll be asked to provide a valid email and the domain set.
openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
{% hint style="info" %}
- You can omit the email.
- Avoid using a common name for the certificate.
- When you renew the certificate, you'll want the Country, State, Locality, and Organization to match what you've input. {% endhint %}
Run the same command to renew your certificate. To remember the options you chose, run the following command:
openssl x509 -in ca.crt -noout -text
Move the CA cert to /etc/ssl/private/client-cert-ca.crt
directory.
Add CA cert, turn on client SSL authentication and add location block.\
ssl_client_certificate /etc/ssl/private/client-cert-ca.crt;
ssl_verify_client optional;
location / {
if ($ssl_client_verify != SUCCESS) {
return 403;
}
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;
}
You can have your users perform most of these steps if you want. But the following are the steps needed to create a certificate to present as client authentication.
openssl genrsa -des3 -out user.key 4096
openssl req -new -key user.key -out user.csr
Answer all of the questions, making sure to include your email address and Common Name (CN). The CSR must be sent to the administrator (or to you if you are handling this on behalf of the user).
As the admin, take the CSR given to you or generated by you and sign the CSR and create a valid certificate:\
openssl x509 -req -days 365 -in user.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out user.crt
You’ll want to increment the serial number with each signing. Once the certificate expires, a new CSR doesn’t need to be recreated; the same one can be signed, which will create a new certificate tied to that public key.
The signed certificate (user.crt) can now be sent back to the user along with the CA cert(ca.crt).
To be able to use in browsers and mobile generate a pkcs #12 using the user cert and key along with the Ca:\
openssl pkcs12 -export -out user.pfx -inkey user.key -in user.crt -certfile ca.crt