I am experimenting to see if it is possible to offload TLS termination in front of Asterisk TCP SIP.
I currently have HAProxy running on 192.168.3.29:5061, terminating TLS (in TCP mode) and forwarding requests to my Asterisk server listening for TCP at 192.168.3.23:5060.
Caller1 can start calls as expected, but things start to fall apart when Asterisk send an INVITE to Caller2 through HAProxy. Asterisk sets the Contact as sip:asterisk@WAN:5061;transport=TCP.
Linphone receives the INVITE over TLS, but the URI is ‘sip’ instead of ‘sips’ and transport=TCP.
2025-04-21 19:20:50:662 [org.linphone/belle-sip] MESSAGE channel [0xb4000072d65a6d20]: received [1079] new bytes from [TLS://jruehlig.com:5061]:
INVITE sip:joshua@192.168.3.29:61553;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 73.192.144.236:5061;rport;branch=z9hG4bKPj6839fb72-1f20-11f0-8fbe-0cc47a418007;alias
From: "Theodore Ruehlig" <sip:1003@192.168.3.23>;tag=6836b420-1f20-11f0-8fbe-0cc47a418007
To: <sip:joshua@192.168.3.29>
Contact: <sip:asterisk@73.192.144.236:5061;transport=TCP>
Call-ID: 6836b454-1f20-11f0-8fbe-0cc47a418007
CSeq: 30007 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, INFO, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 22.3.0
Content-Type: application/sdp
Content-Length: 351
v=0
o=- 1101726724 1101726724 IN IP4 73.192.144.236
s=Asterisk
c=IN IP4 73.192.144.236
t=0 0
m=audio 10272 RTP/SAVP 0 8 107
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:4gVxDgz1YFBCJAY1we5rcG/pwpuZV5U4zpM5rKmY
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:107 opus/48000/2
a=fmtp:107 useinbandfec=1
a=ptime:20
a=maxptime:60
a=sendrecv
Linphone responds over TCP which will not work.
2025-04-21 19:20:50:808 [org.linphone/belle-sip] MESSAGE channel [0xb4000072c7b76e00]: message sent to [TCP://2607:7700:0:13:0:2:49c0:90ec:5061], size: [369] bytes
SIP/2.0 100 Trying
Via: SIP/2.0/TCP 73.192.144.236:5061;received=2607:7700:0:13:0:2:49c0:90ec;rport;branch=z9hG4bKPj6839fb72-1f20-11f0-8fbe-0cc47a418007;alias
From: "Theodore Ruehlig" <sip:1003@192.168.3.23>;tag=6836b420-1f20-11f0-8fbe-0cc47a418007
To: sip:joshua@192.168.3.29
Call-ID: 6836b454-1f20-11f0-8fbe-0cc47a418007
CSeq: 30007 INVITE
Content-Length: 0
Is it possible to rewrite the contact that Asterisk sets? Here is relevant parts of pjsip.conf
[transport-tcp]
type = transport
protocol = tcp
bind = 192.168.3.23
local_net = 192.168.3.23/32
external_media_address = jruehlig.com
external_signaling_address = jruehlig.com
external_signaling_port = 5061
;symmetric_transport = yes
[endpoint-basic](!)
type = endpoint
transport = transport-tcp
;force_rport = no
rtp_symmetric = yes
rewrite_contact = yes
direct_media = no
;ice_support = yes
;media_address = jruehlig.com
;bind_rtp_to_media_address = yes