text
stringlengths
0
152
with any external entity. The disadvantage is that because of this, external entities will
not trust it.
If you are securing SIP devices only for use within your controlled network environ‐
ment, a self-signed certificate may be all you need. This is not considered the best
approach, but in some cases it may be good enough, and it’s generally better than
nothing.
In this world full of automated crime, there is much to learn about privacy and secu‐
rity, and the cryptography necessary to both. However, this is a book about Asterisk,
so what we are going to do is provide a template for generating the required compo‐
nents, and it’ll be up to you to research further.
The openssl toolkit provides a tool that’ll get the job done for us. We’ll run it as fol‐
lows:
$ sudo su asterisk -
$ mkdir /home/asterisk/certs
$ openssl req -x509 -nodes -newkey rsa:2048 -days 3650 \
-keyout /home/asterisk/certs/self-signed.key \
-out /home/asterisk/certs/self-signed.crt
You will be asked to provide some information, and then your key and cert will be
written to the /home/asterisk/certs folder.
You can add the following to the command to bypass the questions (change the infor‐
mation as appropriate to your situation):
-subj "/C=CA/ST=Ontario/L=Toronto/O=ShiftEight/CN=shifteight.org"
The full command should then look something like this:
$ openssl req -x509 -nodes -newkey rsa:2048 -days 3650 \
> -keyout /home/asterisk/certs/self-signed.key \
Securing SIP
|
51
> -out /home/asterisk/certs/self-signed.crt \
> -subj "/C=CA/ST=Ontario/L=Toronto/O=ShiftEight/CN=shifteight.org"
This will generate a self-signed certificate and a private key, and save them both to /
home/asterisk/certs/. We can use them later when we are configuring our SIP end‐
points.
It’s probably a good idea to chmod your certs so only the relevant user/group can
access them:
$ chmod 640 /home/asterisk/certs/*
Exit the asterisk user account.
$ exit
$ who am i # You should be astmin again.
There is an alternative to using self-signed certificates: if you have a domain name
assigned to your server that can be reached from the public internet, you can generate
a validated certificate using LetsEncrypt. Read on.
LetsEncrypt certificates
If you are interested in secure communications across the public internet (which you
are, trust us), then having domain certificates provided by a certificate authority (CA)
is useful.
The LetsEncrypt project provides free domain validation (DV) digital certificates.
The free tool provided by the Let’s Encrypt Foundation called certbot allows you to
automate the obtaining and maintenance of trusted certificates.
At a minimum, your server will need a fully qualified domain name (FQDN) that
maps to an external IP address that arrives at the machine. Any firewall in between
will need to pass traffic for that hostname to the system you are obtaining the certifi‐
cate for. If you cannot do this for whatever reason, the obtaining of a trusted certifi‐
cate becomes more complex (and beyond the scope of this book).
certbot can be installed with yum as follows:
$ sudo yum -y install certbot
Once it’s installed, you simply need to run the following:
$ sudo certbot certonly
How would you like to authenticate with the ACME CA?
-------------------------------------------------------------------------------
1: Spin up a temporary webserver (standalone)
2: Place files in webroot directory (webroot)
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
52
|