5

I read that ejabberd recommends to use STARTTLS negotiation for secure connection between communicating entities. When I install ejabberd, by default it comes with a TLS certificate.

Then, why do I need to buy a certificate to install? what is the purpose of buying a new certificate from Certificate Authoririty since we have a default certificate?

When I deploy ejabberd on the machine, how the default certificate will be used for my domain? How the default certificate will be verified by client?

Kamesh
  • 1,435
  • 1
  • 14
  • 27
  • See also the end of the https://github.com/jsxc/xmpp-cloud-auth/wiki/raspberry-pi-en#configuration-of-apache-including-https section and Release information for ejabberd 17.11 at https://blog.process-one.net/ejabberd-17-11-happy-birthday-ejabberd/ – Marcel Waldvogel Aug 29 '18 at 16:32

2 Answers2

2

You can use ejabberd with SSL / STARTTLS with the provided TLS certificate. However, that certificate is only a self-signed certificate. It means that:

  1. You will still be able to encrypt the traffic between the client and the server.
  2. You client will not be able to check that the server is the domain it pretends to be. To be able to know that the certificate can be trusted the client need to refer to a trust authority in some way.

In the second case, it means that if an intermediate network device (i.e Wifi access point) tries to impersonate your server, it can present any self-signed certificate to the user, pretending to be your domain.

So, you can definitely use self-signed certificate to encrypt traffic, but to protect your users against man-in-the-middle type of attacks, you need to find a way to let the client now it can trust the certificate.

This can be done either by buying a certificate from a trusted authority (that will certify your certificate domain) or by making the client support a list of well defined certificates. This is called certificates pinning, however it requires to build the list of acceptable certificates into your client, which may not be possible.

It may be fine in your case, so buying a certificate is not mandatory. However, not use the default ejabberd self-signed certificate, even if you plan using a self-signed certificate. The certificate provided with ejabberd will not match your own domain. You should at least generate your own self signed certificate that match your actual XMPP domain: How to create a self-signed certificate with openssl?

Community
  • 1
  • 1
Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
  • @Michael Very good explanation. Why you are suggesting to not make the use of ejabberd certificate? Is there any specific reason behind it? – Kamesh Jul 29 '15 at 05:45
  • 1
    The provided self certificate use a generic domain, not your actual domain. It is better to at least use your own domain in the certificate. – Mickaël Rémond Jul 29 '15 at 06:41
1

The client will verify whether the certificate is issued for the domain name of the Jabber ID (JID), the part behind the '@'. (There are other options, but they are incompatible with the policies enforced by the browser vendors against CAs and therefore not practical.)

Unless you already have a business relationship to a certificate authority (CA), I would recommend anyone to use Let's Encrypt and stay away from self-signed certificates.

Some instructions to automate this and be nice to the Let's Encrypt servers can be found here and the linked wiki pages.

Summary (assuming you are running Ubuntu 16.04 LTS, want to run it on the domain example.org and only use the certificate for ejabberd):

Create /usr/local/sbin/auto-renew-letsencrypt with the following content:

#!/bin/bash
# Renew all Let's Encrypt certificates which are due for renewal
t=`mktemp`
# Try to be quiet unless an error is returned
letsencrypt renew > $t || cat $t
# Hooks are not yet supported by `letsencrypt` shipping with Ubuntu 16.04 LTE
# Crudely emulate --renew-hook; breaks if diagnostic messages change
if grep -q "The following certs have been renewed" $t; then
  cat /etc/letsencrypt/live/example.org/{privkey,fullchain}.pem > /etc/ejabberd/ejabberd.pem
  service ejabberd reload
fi
rm $t

Run the following commands to create and activate the certificate and the automatic renewal

apt install letsencrypt
letsencrypt certonly --standalone --domain example.org
cat /etc/letsencrypt/live/example.org/{privkey,fullchain}.pem > /etc/ejabberd/ejabberd.pem
chown ejabberd:ejabberd /etc/ejabberd/ejabberd.pem
chmod 640 /etc/ejabberd/ejabberd.pem
chmod 755 /usr/local/sbin/auto-renew-letsencrypt
echo $(($RANDOM % 60)) $((RANDOM % 6)) "* * * root /usr/local/sbin/auto-renew-letsencrypt" > /etc/cron.d/auto-renew-letsencrypt
Marcel Waldvogel
  • 422
  • 3
  • 10