sudo vi /etc/ejabberd/ejabberd.cfg
Modify the line for set certificate value before load the configuration file
[{5222, ejabberd_c2s, [{access, c2s},
{max_stanza_size, 65536},
starttls_required, {certfile, "/etc/ejabberd/server.pem"},
{shaper, c2s_shaper}]},
In the command line generate the key
openssl req -new -x509 -newkey rsa:1024 -days 3650 \
-keyout privkey.pem -out server.pem
openssl rsa -in privkey.pem -out privkey.pem
cat privkey.pem >> server.pem
rm privkey.pem
Finally restart the service
sudo ejabberctl restart