Summary:ASTERISK-21964: SIP TLS Register statement fails if sip.conf register directive uses peer name.
Reporter:Doug Bailey (dbailey)Labels:
Date Opened:2013-06-26 14:13:58Date Closed:2013-08-05 15:18:01
Versions: 11.5.0 Frequency of
Environment:Attachments:( 0) asterisk-21964-set-reg-dialog-transport.diff
Description:I am using 1.8.15-cert2 and have been testing some TLS functionality.  When I set a register statement that specifies TLS and uses the peer name as the target address in the register statement, I get an error and the register request never goes out.

The problem occurs due to a create_addr failing in transmit_register due to an allocated dialog's socket being set to UDP while the sip_registry indicates only TLS transport.

The register statement works if I explicitly specify the IP address in the sip.conf register statement.

From sip.conf
register => tls://dbt:1234@dbt


Error encountered:
[Jun 26 10:43:47] ERROR[9054]: chan_sip.c:5342 create_addr_from_peer: 'UDP' is not a valid transport for 'dbt'. we only use 'TLS'! ending call.
[Jun 26 10:43:47] WARNING[9054]: chan_sip.c:13524 transmit_register: Probably a DNS error for registration to dbt@dbt, trying REGISTER again (after 20 seconds)

If I make the following change, the register statement succeeds:

--- channels/chan_sip.c (revision 392897)
+++ channels/chan_sip.c (working copy)
@@ -13484,7 +13484,11 @@
ast_log(LOG_WARNING, "Unable to allocate registration transaction (memory or socket error)\n");
return 0;
+ if (SIP_TRANSPORT_TLS == r->transport || SIP_TRANSPORT_TCP == r->transport ) {
+ p->socket.type = r->transport;
+ }

This occurs both in 1.8.15-cert2 and in the tip of the 1.8 branch.
Comments:By: Michael L. Young (elguero) 2013-06-26 16:24:53.655-0500

I think it might be as simple as the following one-liner patch.  [^asterisk-21964-set-reg-dialog-transport.diff]

Basically same idea as the patch you put in the description but since the registry transport is always set (either the default UDP or based on parsing the register line), it might be simplified to just setting the transport on the dialog without the conditionals being necessary.  Let me know how if it works for you.

By: Rusty Newton (rnewton) 2013-07-01 17:58:33.712-0500

Doug can you test and report back?

By: Rusty Newton (rnewton) 2013-07-16 17:18:51.924-0500

Doug informed me that he will be testing this soon.

By: Doug Bailey (dbailey) 2013-07-17 16:12:48.104-0500

This fix works in my application.

By: Rusty Newton (rnewton) 2013-07-24 09:48:01.412-0500

Assigning to Michael - feel free to commit unless you think it needs further testing.