I am trying to convert this chan_sip configuration to chan_pjsip.
It’s easy to find many examples for this kind of basic trunk connection without encryption. But I found it pretty hard to find examples online for connections with TLS/SRTP. I would kindly ask for help and guidance.
This working chan_sip configuration connects to our SIP-Provider, keeps the registration stable, encrypts SIP and RTP traffic and puts incoming calls into the [in] section of the Asterisk dialplan. I am a little bit lost because our SIP-provider does not provide documentation on how to do this with chan_pjsip and we finaly decided to move on to “the current driver”.
This config worked for us with an Asterisk behind NAT and a trunk SIP provider with public IP. /etc/ssl/certs is the default CA-cert collection on Debian/Ubuntu. Path may be different with other distributions.
We also activated Asterisks builtin STUN-client.
(/etc/asterisk/res_stun_monitor.conf)
This is our working chan_pjsip.conf:
;/etc/asterisk/pjsip.conf
[transport-tls]
type = transport
protocol = tls
bind = 192.168.0.3:5061
local_net = 192.168.0.0/24
ca_list_path = /etc/ssl/certs
method = tlsv1
[reg_provider.net]
type = registration
retry_interval = 20
max_retries = 0
expiration = 45
transport = transport-tls
outbound_auth = auth_reg_provider.net
client_uri = sip:PROVIDER_USERNAME@provider.net
server_uri = sip:provider.net
[auth_reg_provider.net]
type = auth
password = PROVIDER_PASSWORD
username = PROVIDER_USERNAME
[provider]
type = aor
contact = sip:PROVIDER_USERNAME@provider.net
[provider]
type = identify
endpoint = provider
match = [IP ADRESS OF providers SIP SERVERS]
[provider]
type = auth
username = PROVIDER_USERNAME
password = PROVIDER_PASSWORD
[provider]
type = endpoint
context = in
disallow = all
allow = ulaw
allow = alaw
rtp_symmetric = yes
rtp_keepalive = 10
media_encryption = sdes
tone_zone = de
language = de
outbound_auth = provider
aors = provider
Yes true. We removed them because it worked without them after a test. The internal adresses for the external signaling actually were recommendations from the provider for chan_sip. Maybe they were bogus, but they worked fine.
Now for chan_pjsip, we activated the STUN client in Asterisk, used the providers STUN server and everything is working fine. If NAT issues arise for others, I guess changes to the config would be needed.