Call between tls/dtls configured client and udp configured client fails with 'called a function you should not call'

I’ve looked through other similar topics here and nothing looks similar to problem I have.

So, I’m using pjsip and Asterisk 20.5.2 built by buildozer @ build-3-19-x86_64 on a x86_64 running Linux on 2023-12-22 17:37:15 UTC on alpine linux 3.19 inside docker container.

I have two clients connected in following way:
“Intercom” client uses udp for both sip and rtp

# docker exec hosp-asterisk rasterisk -x 'pjsip show endpoint intercom1'

Endpoint:  intercom1                                            Not in use    0 of inf
    OutAuth:  intercom1/intercom1
     InAuth:  intercom1/intercom1
        Aor:  intercom1                                          1
      Contact:  intercom1/sip:intercom1@192.168.3.165:5060 2d9e929e55 NonQual         nan
  Transport:  transport-udp             udp      0      0  0.0.0.0:5060

 ParameterName                      : ParameterValue
 ===================================================================================================
 100rel                             : yes
 accept_multiple_sdp_answers        : false
 accountcode                        :
 acl                                :
 aggregate_mwi                      : true
 allow                              : (speex|g729|gsm|g723|ulaw|alaw|h264|h263)
 allow_overlap                      : true
 allow_subscribe                    : true
 allow_transfer                     : true
 allow_unauthenticated_options      : false
 aors                               : intercom1
 asymmetric_rtp_codec               : false
 auth                               : intercom1
 bind_rtp_to_media_address          : false
 bundle                             : false
 call_group                         :
 callerid                           : <unknown>
 callerid_privacy                   : allowed_not_screened
 callerid_tag                       :
 codec_prefs_incoming_answer        : prefer:pending, operation:intersect, keep:all, transcode:allow
 codec_prefs_incoming_offer         : prefer:pending, operation:intersect, keep:all, transcode:allow
 codec_prefs_outgoing_answer        : prefer:pending, operation:intersect, keep:all, transcode:allow
 codec_prefs_outgoing_offer         : prefer:pending, operation:union, keep:all, transcode:allow
 connected_line_method              : invite
 contact_acl                        :
 context                            : intercoms-callout
 cos_audio                          : 0
 cos_video                          : 0
 device_state_busy_at               : 0
 direct_media                       : false
 direct_media_glare_mitigation      : none
 direct_media_method                : invite
 disable_direct_media_on_nat        : false
 dtls_auto_generate_cert            : No
 dtls_ca_file                       :
 dtls_ca_path                       :
 dtls_cert_file                     :
 dtls_cipher                        :
 dtls_fingerprint                   : SHA-256
 dtls_private_key                   :
 dtls_rekey                         : 0
 dtls_setup                         : active
 dtls_verify                        : No
 dtmf_mode                          : rfc4733
 fax_detect                         : false
 fax_detect_timeout                 : 0
 follow_early_media_fork            : true
 force_avp                          : false
 force_rport                        : true
 from_domain                        : 192.168.3.253
 from_user                          :
 g726_non_standard                  : false
 geoloc_incoming_call_profile       :
 geoloc_outgoing_call_profile       :
 ice_support                        : false
 identify_by                        : username,ip
 ignore_183_without_sdp             : false
 inband_progress                    : false
 incoming_call_offer_pref           : local
 incoming_mwi_mailbox               :
 language                           :
 mailboxes                          :
 max_audio_streams                  : 1
 max_video_streams                  : 1
 media_address                      :
 media_encryption                   : no
 media_encryption_optimistic        : false
 media_use_received_transport       : false
 message_context                    :
 moh_passthrough                    : false
 moh_suggest                        : default
 mwi_from_user                      :
 mwi_subscribe_replaces_unsolicited : no
 named_call_group                   :
 named_pickup_group                 :
 notify_early_inuse_ringing         : false
 one_touch_recording                : false
 outbound_auth                      : intercom1
 outbound_proxy                     :
 outgoing_call_offer_pref           : remote_merge
 overlap_context                    :
 pickup_group                       :
 preferred_codec_only               : false
 record_off_feature                 : automixmon
 record_on_feature                  : automixmon
 refer_blind_progress               : true
 rewrite_contact                    : true
 rpid_immediate                     : false
 rtcp_mux                           : false
 rtp_engine                         : asterisk
 rtp_ipv6                           : false
 rtp_keepalive                      : 0
 rtp_symmetric                      : false
 rtp_timeout                        : 0
 rtp_timeout_hold                   : 0
 sdp_owner                          : -
 sdp_session                        : Asterisk
 security_mechanisms                :
 security_negotiation               : no
 send_aoc                           : false
 send_connected_line                : yes
 send_diversion                     : true
 send_history_info                  : false
 send_pai                           : false
 send_rpid                          : false
 set_var                            :
 srtp_tag_32                        : false
 stir_shaken                        : off
 stir_shaken_profile                :
 sub_min_expiry                     : 0
 subscribe_context                  :
 suppress_q850_reason_headers       : false
 t38_bind_udptl_to_media_address    : false
 t38_udptl                          : false
 t38_udptl_ec                       : none
 t38_udptl_ipv6                     : false
 t38_udptl_maxdatagram              : 0
 t38_udptl_nat                      : false
 timers                             : yes
 timers_min_se                      : 90
 timers_sess_expires                : 1800
 tone_zone                          :
 tos_audio                          : 0
 tos_video                          : 0
 transport                          : transport-udp
 trust_connected_line               : yes
 trust_id_inbound                   : false
 trust_id_outbound                  : false
 use_avpf                           : false
 use_ptime                          : false
 user_eq_phone                      : false
 voicemail_extension                :
 webrtc                             : no

and “User” client that uses tls/dtsl:

docker exec hosp-asterisk rasterisk -x 'pjsip show endpoint vlocal10011'

 Endpoint:  vlocal10011                                          Not in use    0 of inf
     InAuth:  vlocal10011/vlocal10011
        Aor:  vlocal10011                                        1
      Contact:  vlocal10011/sip:vlocal10011@192.168.3.137: 7d8cbb28e0 NonQual         nan
  Transport:  transport-tls             tls      0      0  0.0.0.0:5061


 ParameterName                      : ParameterValue
 ===================================================================================================
 100rel                             : yes
 accept_multiple_sdp_answers        : false
 accountcode                        :
 acl                                :
 aggregate_mwi                      : true
 allow                              : (speex|g729|alaw|ulaw|h263|h264)
 allow_overlap                      : true
 allow_subscribe                    : true
 allow_transfer                     : true
 allow_unauthenticated_options      : false
 aors                               : vlocal10011
 asymmetric_rtp_codec               : false
 auth                               : vlocal10011
 bind_rtp_to_media_address          : false
 bundle                             : false
 call_group                         :
 callerid                           : <unknown>
 callerid_privacy                   : allowed_not_screened
 callerid_tag                       :
 codec_prefs_incoming_answer        : prefer:pending, operation:intersect, keep:all, transcode:allow
 codec_prefs_incoming_offer         : prefer:pending, operation:intersect, keep:all, transcode:allow
 codec_prefs_outgoing_answer        : prefer:pending, operation:intersect, keep:all, transcode:allow
 codec_prefs_outgoing_offer         : prefer:pending, operation:union, keep:all, transcode:allow
 connected_line_method              : invite
 contact_acl                        :
 context                            : outbound-op
 cos_audio                          : 0
 cos_video                          : 0
 device_state_busy_at               : 0
 direct_media                       : false
 direct_media_glare_mitigation      : none
 direct_media_method                : invite
 disable_direct_media_on_nat        : false
 dtls_auto_generate_cert            : No
 dtls_ca_file                       :
 dtls_ca_path                       : /etc/ssl/certs/
 dtls_cert_file                     : /run/secrets/asterisktlscert
 dtls_cipher                        :
 dtls_fingerprint                   : SHA-256
 dtls_private_key                   : /run/secrets/asterisktlskey
 dtls_rekey                         : 0
 dtls_setup                         : actpass
 dtls_verify                        : Yes
 dtmf_mode                          : auto
 fax_detect                         : false
 fax_detect_timeout                 : 0
 follow_early_media_fork            : true
 force_avp                          : false
 force_rport                        : true
 from_domain                        : nightsterisk.devc.acme.com
 from_user                          :
 g726_non_standard                  : false
 geoloc_incoming_call_profile       :
 geoloc_outgoing_call_profile       :
 ice_support                        : false
 identify_by                        : username,ip
 ignore_183_without_sdp             : false
 inband_progress                    : false
 incoming_call_offer_pref           : local
 incoming_mwi_mailbox               :
 language                           :
 mailboxes                          :
 max_audio_streams                  : 1
 max_video_streams                  : 1
 media_address                      : 192.168.3.253
 media_encryption                   : dtls
 media_encryption_optimistic        : false
 media_use_received_transport       : true
 message_context                    :
 moh_passthrough                    : false
 moh_suggest                        : default
 mwi_from_user                      :
 mwi_subscribe_replaces_unsolicited : no
 named_call_group                   :
 named_pickup_group                 :
 notify_early_inuse_ringing         : false
 one_touch_recording                : false
 outbound_auth                      :
 outbound_proxy                     :
 outgoing_call_offer_pref           : remote_merge
 overlap_context                    :
 pickup_group                       :
 preferred_codec_only               : false
 record_off_feature                 : automixmon
 record_on_feature                  : automixmon
 refer_blind_progress               : true
 rewrite_contact                    : true
 rpid_immediate                     : false
 rtcp_mux                           : false
 rtp_engine                         : asterisk
 rtp_ipv6                           : false
 rtp_keepalive                      : 0
 rtp_symmetric                      : false
 rtp_timeout                        : 0
 rtp_timeout_hold                   : 0
 sdp_owner                          : -
 sdp_session                        : Asterisk
 security_mechanisms                :
 security_negotiation               : no
 send_aoc                           : false
 send_connected_line                : yes
 send_diversion                     : true
 send_history_info                  : false
 send_pai                           : false
 send_rpid                          : false
 set_var                            :
 srtp_tag_32                        : false
 stir_shaken                        : off
 stir_shaken_profile                :
 sub_min_expiry                     : 0
 subscribe_context                  :
 suppress_q850_reason_headers       : false
 t38_bind_udptl_to_media_address    : false
 t38_udptl                          : false
 t38_udptl_ec                       : none
 t38_udptl_ipv6                     : false
 t38_udptl_maxdatagram              : 0
 t38_udptl_nat                      : false
 timers                             : yes
 timers_min_se                      : 90
 timers_sess_expires                : 1800
 tone_zone                          :
 tos_audio                          : 0
 tos_video                          : 0
 transport                          : transport-tls
 trust_connected_line               : yes
 trust_id_inbound                   : false
 trust_id_outbound                  : false
 use_avpf                           : false
 use_ptime                          : false
 user_eq_phone                      : false
 voicemail_extension                :
 webrtc                             : no

When I try to make call from “User” to “Intercom” sip seems to work just fine and bridge is created on asterisk, but then suddenly call drops with following messages in the logs:

[2024-01-31 10:27:16.340] VERBOSE[768][C-00000003] app_dial.c: Called PJSIP/intercom1
[2024-01-31 10:27:16.465] VERBOSE[768][C-00000003] app_dial.c: PJSIP/intercom1-00000005 is ringing
[2024-01-31 10:27:16.469] VERBOSE[768][C-00000003] app_dial.c: PJSIP/intercom1-00000005 answered PJSIP/vlocal10011-00000004
[2024-01-31 10:27:16.473] VERBOSE[769][C-00000003] bridge_channel.c: Channel PJSIP/intercom1-00000005 joined 'simple_bridge' basic-bridge <ee84ed42-5a13-4b45-b849-aa8cc3c67375>
[2024-01-31 10:27:16.474] VERBOSE[768][C-00000003] bridge_channel.c: Channel PJSIP/vlocal10011-00000004 joined 'simple_bridge' basic-bridge <ee84ed42-5a13-4b45-b849-aa8cc3c67375>
[2024-01-31 10:27:17.009] ERROR[768][C-00000003] res_rtp_asterisk.c: DTLS failure occurred on RTP instance '0x7f0fe3253ee0' due to reason 'called a function you should not call', terminating
[2024-01-31 10:27:17.010] WARNING[768][C-00000003] res_rtp_asterisk.c: RTP Read error: Invalid argument.  Hanging up.
[2024-01-31 10:27:17.011] VERBOSE[768][C-00000003] bridge_channel.c: Channel PJSIP/vlocal10011-00000004 left 'simple_bridge' basic-bridge <ee84ed42-5a13-4b45-b849-aa8cc3c67375>
[2024-01-31 10:27:17.012] VERBOSE[769][C-00000003] bridge_channel.c: Channel PJSIP/intercom1-00000005 left 'simple_bridge' basic-bridge <ee84ed42-5a13-4b45-b849-aa8cc3c67375>

Error is

DTLS failure occurred on RTP instance '0x7f0fe3253ee0' due to reason 'called a function you should not call', terminating

This error message most likely comes from openssl library here:

which is probably called from asterisk code here:

I’ve tried this setup on lower and lower Asterisk versions and it eventually worked on Asterisk 16.6.2 (Alpine 3.11 in container).

So is this a bug in Asterisk or something wrong with my setup?

@jcolp Hi, maybe you can help with this please?

Please don’t tag people. If people, including myself, want to participate in threads then they will do so.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.