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
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.
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 -datesConfigure a TLS transport
[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.20verify_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.
A TCP/TLS signaling listener with fake certificate paths.
It protects SIP signaling on each configured hop.
Listener is bound, certificate is valid and peer verification succeeds.
Listener inspection, PJSIP transport status and TLS handshake.
Read the certificate alert; check chain, name, time and key permissions.
Restore prior transport and use the release-appropriate restart window if required.
The private key is a high-value secret; TLS does not protect RTP.
Configure media encryption deliberately
[carrier-endpoint-sdes]
type=endpoint
transport=transport-tls
aors=carrier-aor
disallow=all
allow=ulaw
media_encryption=sdes
media_encryption_optimistic=no
direct_media=nomedia_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.
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/8000Verify listener and handshake
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/nullCONNECTED(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
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 offInspect 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
| Evidence | Interpretation | Action |
|---|---|---|
| Unknown CA / unable to get issuer | Trust chain incomplete or wrong trust store. | Install the agreed CA chain; do not disable verification. |
| Hostname mismatch | Certificate identity does not match connection name. | Correct DNS/URI or certificate issuance. |
| Certificate not yet valid / expired | Clock or lifecycle failure. | Correct UTC or renew certificate. |
| Private key mismatch | Key does not correspond to leaf certificate. | Install the matching protected key. |
| TLS succeeds; 488 follows | Signaling encrypted, media offer rejected. | Compare RTP profile, codecs and crypto/fingerprint. |
| Plain RTP profile in SDP | SRTP not negotiated for that leg. | Inspect endpoint selection and media_encryption. |
Rollback and recovery
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-provided value | Object or parameter that consumes it |
|---|---|
| Peer FQDN, port and TLS version | transport and endpoint |
| Trusted CA and expected certificate name | TLS verification and trust store |
| Supported SRTP method | endpoint media_encryption |
| Certificate renewal expectations | certificate paths and operational runbook |
Implementation closure
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.
Asterisk PJSIP transport and endpoint objects, certificate/key files, trust store, firewall listener, and peer TLS/SRTP policy.
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.
TLS handshake and hostname validation succeed, the intended transport is selected, SDP negotiates the approved SRTP profile, and encrypted media is bidirectional.
Separate certificate-chain, hostname, protocol/cipher, transport selection, SDP profile, keying, and RTP reachability failures.
Stop if certificate verification must be disabled, keys are exposed, the peer security profile is unknown, or no rollback listener remains.
Signaling and media protections are independently verified, renewal/reload behavior is tested, the old path can be restored, and secrets remain protected.