Pre-Submission Checklist

Type Of Change

Checklist:

Description

PR adds new core option tls_connection_match_domain with the default value 0 (old behavior)
to solve the problem when we need to have multiple TLS connections with different SNI to the same host:port endpoint.
for example: multiple customers (authorized by cert) for MS Teams on the single kamailio instance.

originally, functions _tcpconn_find and _tcpconn_add_alias_unsafe use only endpoint and protocol to match connections.
setting tls_connection_match_domain to 1 will match additionaly with tls_domain_str() output for matched TLS domain.
as a result, we will be able to establish new TLS connections if TLS domain is changed instead of reusing of the existent one with the wrong SNI.

i'm not considering this PR as the final version but we need something to start with. looking forward for any input.

FIXME: not found the right place where new core option should be documented.

Behavior difference example

#!KAMAILIO

listen=udp:127.0.0.1:5060
listen=tls:127.0.0.1:5061

enable_tls = yes
tls_connection_match_domain = 1

debug = 3

loadmodule "tls.so"
modparam("tls", "config", "/etc/kamailio/tls.cfg")
modparam("tls", "xavp_cfg", "tls")

loadmodule "ctl.so"
loadmodule "pv.so"
loadmodule "tm.so"

route {
    $xavp(tls=>server_id) = $rU;
    t_relay_to_tls("127.0.0.1", 5081);
}
[server:default]
certificate = /etc/ssl/certs/ssl-cert-snakeoil.pem
private_key = /etc/ssl/private/ssl-cert-snakeoil.key

[client:any]
server_name = server_name_1.invalid
server_id = 1

[client:any]
server_name = server_name_2.invalid
server_id = 2
$ openssl s_server -port 5081 -cert /etc/ssl/certs/ssl-cert-snakeoil.pem -key /etc/ssl/private/ssl-cert-snakeoil.key
$ for u in 1 2; do sipp -sn uac -m 1 -nd -recv_timeout 1 -bg -s $u 127.0.0.1:5060; done
# kamcmd tls.list
{
        id: 1
        dom: TLSc<any:server_name_1.invalid>
        sni: N/A
        timestamp: 2025-04-24 14:07:20
        timeout: 118
        src_ip: 127.0.0.1
        src_port: 5081
        dst_ip: 127.0.0.1
        dst_port: 58808
        cipher: unknown
        ct_wq_size: 1162
        enc_rd_buf: 0
        flags: 1
        state: tls_connect
}
# kamcmd tls.list
{
        id: 1
        dom: TLSc<any:server_name_1.invalid>
        sni: N/A
        timestamp: 2025-04-24 14:09:10
        timeout: 117
        src_ip: 127.0.0.1
        src_port: 5081
        dst_ip: 127.0.0.1
        dst_port: 55480
        cipher: unknown
        ct_wq_size: 581
        enc_rd_buf: 0
        flags: 1
        state: tls_connect
}
{
        id: 2
        dom: TLSc<any:server_name_2.invalid>
        sni: N/A
        timestamp: 2025-04-24 14:09:10
        timeout: 117
        src_ip: 127.0.0.1
        src_port: 5081
        dst_ip: 127.0.0.1
        dst_port: 55488
        cipher: unknown
        ct_wq_size: 581
        enc_rd_buf: 0
        flags: 1
        state: tls_connect
}

You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/4222

Commit Summary

File Changes

(14 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <kamailio/kamailio/pull/4222@github.com>