Asterisk TLS and SRTP: signalling, media and certificate trust
Protecting a SIP connection and protecting the audio are separate tasks. Describe the exact peer and call leg covered by each setting. A lock icon or a successful TLS connection does not establish encryption across an entire multi-leg call.
Source-reviewed, 20 October 2026. Prepared from the cited documentation. No encrypted call path has been independently tested by Phone Guides. Scope: Asterisk 22/PJSIP planning; exact transport, certificate and media-encryption support depends on each peer and build.
Separate the protections
| Item | What it addresses | What it does not establish alone |
|---|---|---|
| TLS for SIP | Protection of the configured signalling connection | Encryption of the audio or every later call leg |
| SRTP media policy | Protection of negotiated media under the selected keying method | That the peer's identity or certificate was checked correctly |
| Certificate validation | Trust and name checks for the configured peer relationship | Dialplan calling permissions |
| Network restrictions | Which sources may reach a service | Application-level identity or permission for every destination |
Start with the security baseline, then record which component terminates each protected connection. A provider, SBC or gateway can be a separate boundary from a phone registered to Asterisk.
Choose the peer's documented method
For each endpoint/trunk, record supported SIP transport, media-encryption/keying method, required names, certificate authority/trust expectations and firmware/service scope. Choose options from the branch-22 PJSIP reference. Do not infer that a phone supports every listed mode because it supports SIP.
Use the PJSIP transport-selection guide to check how an outbound request selects TLS. The PJSIP section and relationship guide explains when transport changes take effect.
Keep method selection explicit when the route changes technology or terminates at an external provider. An encrypted local leg does not establish that the provider's onward network uses the same protection.
For an endpoint that requires SRTP, media_encryption=sdes selects SDES keying in the SDP; Asterisk's branch-22 reference says to use encrypted SIP transport with it so those keys are not exposed. media_encryption=dtls selects DTLS-SRTP; use it only when the peer's documented setup calls for that method. media_encryption_optimistic=yes can allow a session to continue without achieving the requested encryption; Asterisk's tagged 22.11.0 sample describes it as allowing the call to continue if encryption is unavailable. Leave it disabled when the endpoint's policy requires protected media and verify the negotiated result.
An endpoint fragment for a peer that documents TLS plus SDES might look like this:
[secure-peer]
type=endpoint
transport=tls-to-peer
media_encryption=sdes
media_encryption_optimistic=no
This fragment does not define authentication, an AOR, routing or the TLS transport. It applies to this endpoint only; check the other call leg separately.
Keep verification intact
Use a certificate whose identity matches the name the peer is configured to validate, with the appropriate trust chain. Record certificate/private-key locations, runtime access, renewal owner and expiry monitoring. Protect private keys and keep them out of documentation and logs.
The older official secure-calling tutorial contains historical driver examples and suggestions to disable verification when names do not match. Those are not the workflow adopted here. Resolve the identity/trust configuration against the current peer requirements rather than bypassing verification to make a connection succeed.
Set certificate checks for the correct direction
The Asterisk 22 PJSIP reference lists verify_server, require_client_cert and verify_client as separate TLS transport settings; these options are not for WSS. For an outbound TLS relationship, verify_server=yes requests verification of the remote server certificate. A server that requires mutual TLS must separately decide whether to require a client certificate and verify it. Enabling only one of those checks does not mean the other check is active. Confirm the exact trust and client-certificate policy with the peer and installed Asterisk/PJSIP build.
This is a transport fragment only. Replace the example paths with files installed and protected for the actual peer; the CA file must contain the trust certificates appropriate to that peer. The Asterisk cert_file setting reads the certificate, while priv_key_file supplies its matching private key:
[tls-to-peer]
type=transport
protocol=tls
bind=192.0.2.10:5061
cert_file=/etc/asterisk/keys/local-certificate.pem
priv_key_file=/etc/asterisk/keys/local-private-key.pem
ca_list_file=/etc/asterisk/keys/peer-trust.pem
verify_server=yes
Do not put a private key in a public certificate file or copy the sample paths as real paths. Restrict key-file access to the service identity and follow the certificate issuer's renewal and chain instructions.
Apply the transport change deliberately
Preserve the previous configuration and identify whether the transport change needs a restart on the installed version. Replacing the transport while users are calling is a service change, not merely a phone password update. Use files and reloads for that distinction.
For Asterisk 22, the branch reference says transport changes require a full restart unless that transport has allow_reload=yes. This setting defaults to no; the documentation warns that reloading a transport may disrupt in-progress calls. Do not enable it simply to avoid scheduling a restart. Check the installed branch and use a planned change procedure; record the active transport and certificate state again afterward.
The method option also depends on the installed PJSIP library. The branch-22 reference lists default as the PJSIP default, described there as currently TLSv1, and says the available methods vary by the underlying library. Do not carry sslv23 or another setting forward from an old tutorial without checking the current release's option help, library support and peer policy. Confirm the actual TLS handshake with a controlled check rather than relying on the text configuration alone.
Restrict any new listener to the intended sources and interface. Do not leave a less-protected fallback reachable accidentally while describing the account as requiring encryption. Inspect the loaded policy and actual negotiated path in your own checks.
Reader verification
Check successful trust/name validation separately from account authentication. Then confirm the negotiated media protection on both relevant legs, two-way audio, DTMF and clean hangup. Include a peer with an untrusted or mismatched certificate to verify the intended refusal behaviour using a controlled procedure.
Record exact versions and evidence when you perform those checks. If a call only works after relaxing the policy, that is a different path and should not be reported as the original protected configuration succeeding.
For registration or audio failures, examine the relevant stage using first troubleshooting checks and NAT/RTP. Return to Asterisk documentation.