FreeSWITCH supports the encryption of SIP signaling traffic via SSL and/or TLS. The convention is to run the SIPS on port 5061. More complex configurations are possible, however they will not be covered in this documentation.
You will need the following in order to compile FreeSWITCH with TLS encryption support:
- OpenSSL-Dev package installed.
If you do not have the OpenSSL-Dev package installed the problem is the sip_profile that contains the encryption configuration directives specified below in Step 2 will fail to start. If you’ve compiled FreeSWITCH without this package installed, there will be no support for encryption and you will need to re-compile it after you install the OpenSSL-Dev package.
For debian do aptitude install libssl and then compile.
Step 1 – Generate the CA Certificate
To use TLS you need at least two certificates: the root certificate (CA) and a certificate for every server. There is a script at /{prefix}/freeswitch/bin/gentls_cert or within the source tarball {tarball}/scripts/gentls_cert that helps generate these files. With
./gentls_cert setup
You can create a new root certificate that will be stored at /{prefix}/freeswitch/conf/ssl/cafile.pem. It will be used to digitally sign all server certificates and must normally be installed also on every phone.
Step 2 – Generate the Server Certificate
The command:
./gentls_cert create -cn freeswitch.org -alt DNS:freeswitch.org
creates the server certificate at /{prefix}/freeswitch/conf/ssl/agent.pem. This file contains the certificate and the private key. It should contain the domain name in the common and alternate name.
To set up new CA and create new certificate under Windows go here.
In order for the new certificate to take effect only way for FS to use it to restart FS.
Step 3 – Sofia Profile Configuration
On your vars.xml.
ATTENTION: TLS is disabled by default, set internal_ssl_enable and/or external_ssl_enable to “true” to enable.
Step 4 – Securing the RTP Channels (optional)
Calls that originate from the phone have sip_secure_media set if tls is setup. Check the global extension. There is a section commented that out will require SRTP on the outbound leg if the inbound leg is encrypted. Enabling this will be problematic with most ITSPs since they do not support tls.
For calls that originate from FreeSWITCH (or routed through) and are terminated on the user/ endpoint (eg: calls to a phone), the following change will enable srtp if the endpoint registered with tls. Note that it is a valid configuration to register with tls but not require srtp. This disables that valid configuration option for user/ endpoints. It would also require further refinement to support ZRTP on user/ endpoints that connect with tls. In that case, a better approach would be to set something on the user’s directory entry that specifies which RTP encryption to support. (in other words, there is a reason this is not the default setting)
Edit conf/directory/default.xml and change the dial-string param to:
<param name="dial-string" value="{sip_secure_media=${regex(${sofia_contact(${dialed_user}@${dialed_domain})}|transport=tls)},presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}" />
Why it’s a good idea
In the SIP Encryption Primer above we discussed why encrypting the RTP data may be a good idea. This is largely done in the Dialplan and has it’s own page dedicated to it’s functionality.
SRTP by itself without TLS is not secure since the keys are exchanged between the two endpoints in the clear over SIP, which is insecure without TLS or SSL.
See Secure RTP page of the FreeSWITCH Wiki for how to deploy SRTP.
For completely secure connection (signaling + media) use TLS + SRTP. TLS without SRTP secures SIP. SRTP without TLS does not really secure RTP !
<!--
SIP and TLS settings.
-->
<X-PRE-PROCESS cmd="set" data="sip_tls_version=tlsv1"/>
<!-- Internal SIP Profile -->
<X-PRE-PROCESS cmd="set" data="internal_auth_calls=true"/>
<X-PRE-PROCESS cmd="set" data="internal_sip_port=5060"/>
<X-PRE-PROCESS cmd="set" data="internal_tls_port=5061"/>
<X-PRE-PROCESS cmd="set" data="internal_ssl_enable=false"/>
<X-PRE-PROCESS cmd="set" data="internal_ssl_dir=$${base_dir}/conf/ssl"/>
<!-- External SIP Profile -->
<X-PRE-PROCESS cmd="set" data="external_auth_calls=false"/>
<X-PRE-PROCESS cmd="set" data="external_sip_port=5080"/>
<X-PRE-PROCESS cmd="set" data="external_tls_port=5081"/>
<X-PRE-PROCESS cmd="set" data="external_ssl_enable=false"/>
<X-PRE-PROCESS cmd="set" data="external_ssl_dir=$${base_dir}/conf/ssl"/>
Recent Comments