ARCAMUSA VOICE ENGINEERING

Asterisk SIP TLS and SRTP: Secure Signaling and Media Guide

Distinguish TLS signaling from SRTP media and validate certificates, transport selection and encryption negotiation as separate controls.

TLS and SRTP protect different paths

TLS encrypts and authenticates the signaling transport hop by hop; it does not encrypt RTP. SRTP protects media packets, but its keys must be negotiated through an appropriate signaling mechanism such as SDES or DTLS-SRTP. A TLS listener with plain RTP is signaling-only encryption. A mixed design can be valid only when its trust boundaries and peer requirements are explicit.

Certificate and key prerequisites

SENSITIVE OUTPUTPRODUCTION CAUTION

Use a certificate whose identity matches the peer’s connection target and whose chain is trusted under the agreed policy. The private key must be readable by Asterisk but not by unprivileged users. Track expiry, renewal, file ownership and whether Asterisk reloads renewed material. The fake paths below do not identify any production certificate.

Certificate preparation patternWARNING / DO NOT COPY BLINDLYBASH
sudo install -d -o asterisk -g asterisk -m 750 /etc/asterisk/keys/example
sudo install -o asterisk -g asterisk -m 640 fullchain.pem /etc/asterisk/keys/example/fullchain.pem
sudo install -o asterisk -g asterisk -m 640 private.key /etc/asterisk/keys/example/private.key
openssl x509 -in /etc/asterisk/keys/example/fullchain.pem -noout -subject -issuer -dates

Configure a TLS transport

CONFIG CHANGERESTART MAY BE REQUIRED
/etc/asterisk/pjsip.confCONFIGINI
[transport-tls]
type=transport
protocol=tls
bind=0.0.0.0:5061
cert_file=/etc/asterisk/keys/example/fullchain.pem
priv_key_file=/etc/asterisk/keys/example/private.key
method=tlsv1_2
verify_server=yes
verify_client=no
require_client_cert=no
external_signaling_address=198.51.100.20
external_media_address=198.51.100.20

verify_server=yes is relevant when Asterisk acts as TLS client and must validate the remote certificate. Client-certificate requirements are a separate inbound policy agreed with the peer. Do not default to disabling verification to silence a chain or hostname error; repair the trust chain, DNS name, clock or peer configuration.

WHAT THIS CONFIGURES

A TCP/TLS signaling listener with fake certificate paths.

WHY IT EXISTS

It protects SIP signaling on each configured hop.

EXPECTED STATE

Listener is bound, certificate is valid and peer verification succeeds.

VERIFY WITH

Listener inspection, PJSIP transport status and TLS handshake.

IF IT FAILS

Read the certificate alert; check chain, name, time and key permissions.

ROLLBACK

Restore prior transport and use the release-appropriate restart window if required.

SECURITY IMPACT

The private key is a high-value secret; TLS does not protect RTP.

Configure media encryption deliberately

CONFIG CHANGERELOAD REQUIRED
PJSIP endpoint — SRTP SDES exampleCONFIGINI
[carrier-endpoint-sdes]
type=endpoint
transport=transport-tls
aors=carrier-aor
disallow=all
allow=ulaw
media_encryption=sdes
media_encryption_optimistic=no
direct_media=no

media_encryption=sdes requests SRTP using crypto attributes carried in SDP. Those keying attributes are protected only if the signaling path is adequately protected; logging SDP can disclose key material. DTLS-SRTP uses a different negotiation model and must match the endpoint capability. Do not enable an encryption mode that the peer has not agreed to support.

Illustrative SDES offer — key redactedSIP TRACESIP
m=audio 16422 RTP/SAVP 0 101
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:REDACTED_EXAMPLE_KEY_MATERIAL
a=rtpmap:0 PCMU/8000

Verify listener and handshake

READ ONLYSENSITIVE OUTPUT
TLS verification commandsCOMMANDBASH
sudo ss -lntp | grep ':5061'
sudo asterisk -rx "pjsip show transports"
openssl s_client -connect sip.example.net:5061 -servername sip.example.net -showcerts </dev/null
Illustrative healthy TLS resultOUTPUTCONSOLE
CONNECTED(00000003)
Protocol  : TLSv1.3
Verify return code: 0 (ok)
# Illustrative output; protocol depends on both endpoints.

A successful OpenSSL verification tests the target presented to that client; it is not proof that Asterisk selected the same transport or that SIP authentication and calls work. Confirm the PJSIP transport on the actual INVITE. A bound listener proves only local socket state.

Validate call negotiation

Asterisk validationCOMMANDBASH
sudo asterisk -rx "module show like res_pjsip"
sudo asterisk -rx "pjsip show transport transport-tls"
sudo asterisk -rx "pjsip show endpoint carrier-endpoint-sdes"
# During one authorized call:
pjsip set logger on
pjsip set logger off

Inspect whether the endpoint resolves to the TLS transport and whether SDP uses an encrypted RTP profile and expected keying attribute. Confirm actual SRTP packets in both directions and audio quality. Avoid retaining full SDES traces; redact key material before incident sharing.

Common certificate and encryption failures

TLS/SRTP evidence matrix
EvidenceInterpretationAction
Unknown CA / unable to get issuerTrust chain incomplete or wrong trust store.Install the agreed CA chain; do not disable verification.
Hostname mismatchCertificate identity does not match connection name.Correct DNS/URI or certificate issuance.
Certificate not yet valid / expiredClock or lifecycle failure.Correct UTC or renew certificate.
Private key mismatchKey does not correspond to leaf certificate.Install the matching protected key.
TLS succeeds; 488 followsSignaling encrypted, media offer rejected.Compare RTP profile, codecs and crypto/fingerprint.
Plain RTP profile in SDPSRTP not negotiated for that leg.Inspect endpoint selection and media_encryption.

Rollback and recovery

PRODUCTION CAUTION

If the peer cannot negotiate the approved secure profile, stop the test rather than silently weakening verification. Restore the previous transport and endpoint from backup, apply the narrow supported reload or controlled restart, and verify baseline signaling and media. Remove temporary certificate copies and trace files. A temporary plaintext fallback requires an explicit security decision, defined duration and monitored compensating controls.

Related engineering resources

Renewal, reload and staged validation

Certificate renewal is an operational change even when automated. Test the new chain and key pairing before activation, retain the prior certificate for a bounded rollback period, and determine whether the installed Asterisk transport can consume renewed files through reload or requires a restart. Coordinate with the peer when mutual TLS pins a certificate or issuing chain. A file renewed on disk is not evidence that an existing process loaded it.

Stage validation in layers: first verify file ownership and dates, then a local listener, then an outbound TLS handshake with hostname validation, then an authenticated SIP transaction, and finally SRTP in both directions. Monitor expiry and handshake failures. Never log SDES key material as routine telemetry, and never put private keys or certificate enrollment credentials in the public repository.

Authoritative references

Inputs you need from your peer

Peer input to configuration mapping
Peer-provided valueObject or parameter that consumes it
Peer FQDN, port and TLS versiontransport and endpoint
Trusted CA and expected certificate nameTLS verification and trust store
Supported SRTP methodendpoint media_encryption
Certificate renewal expectationscertificate paths and operational runbook

Implementation closure

Inputs required

Peer FQDN/port → transport and endpoint; trusted CA and certificate name → TLS verification; SRTP method/profile → media_encryption; certificate/key paths → transport; cipher/version policy → TLS settings.

Change surface

Asterisk PJSIP transport and endpoint objects, certificate/key files, trust store, firewall listener, and peer TLS/SRTP policy.

Apply and reload semantics

Validate files, permissions, names, and a parallel listener before moving traffic. Transport changes may require a scheduled Asterisk restart; endpoint media-policy changes may be reloadable on the installed branch.

Healthy result

TLS handshake and hostname validation succeed, the intended transport is selected, SDP negotiates the approved SRTP profile, and encrypted media is bidirectional.

Failure path

Separate certificate-chain, hostname, protocol/cipher, transport selection, SDP profile, keying, and RTP reachability failures.

Stop conditions

Stop if certificate verification must be disabled, keys are exposed, the peer security profile is unknown, or no rollback listener remains.

Definition of done

Signaling and media protections are independently verified, renewal/reload behavior is tested, the old path can be restored, and secrets remain protected.

Last substantively reviewed: 2026-09-13