sipwise / rtpengine

The Sipwise media proxy for Kamailio
GNU General Public License v3.0
786 stars 369 forks source link

Failed to init DTLS connection: key values mismatch #1524

Closed vadimd333 closed 1 year ago

vadimd333 commented 2 years ago

Hello!

I have a schema: WebRTC (SRTP) -> OpenSIPS (SIP/RTP) -> Asterisk. When the WS-client (JsSIP) calls to the above schema i see the following lines in the log file:

Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Adding codec rtx/90000 (117) Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Adding codec ulpfec/90000 (118) Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Updating supplemental codecs for #2 Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Setting up codec handlers for #2 -> pm9rcej958 #2 Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Checking receiver codec VP8/90000/1 (96) Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Creating codec handler for VP8/90000 (96) Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] No codec support for VP8/90000 Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Using passthrough handler for VP8/90000 with DTMF -1, CN -1 Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Checking receiver codec rtx/90000/1 (97) Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Creating codec handler for rtx/90000 (97) Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] No codec support for rtx/90000 Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Using passthrough handler for rtx/90000 with DTMF -1, CN -1 Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Checking receiver codec VP9/90000/1 (98) Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Creating codec handler for VP9/90000 (98) Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] No codec support for VP9/90000 Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Using passthrough handler for VP9/90000 with DTMF -1, CN -1 Aug 8 10:25:18 proxy-01 rtpengine[30571]: DEBUG: [qn3csvi7broe24ic19kl]: [codec] Checking receiver codec rtx/90000/1 (99) Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl]: [control] Replying to 'offer' from 127.0.0.1:57153 (elapsed time 0.134197 sec) Aug 8 10:25:18 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl]: [control] Received command 'offer' from 127.0.0.1:57153 Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl]: [control] Replying to 'offer' from 127.0.0.1:57153 (elapsed time 0.029619 sec) Aug 8 10:25:18 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl]: [control] Received command 'answer' from 127.0.0.1:60877 Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl]: [crypto] Failed to init DTLS connection: key values mismatch Aug 8 10:25:18 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl]: [control] Replying to 'answer' from 127.0.0.1:60877 (elapsed time 0.034237 sec) Aug 8 10:25:19 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl port 10062]: [ice] ICE negotiated: peer for component 1 is 188.23.81.254:59760 Aug 8 10:25:19 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl port 10062]: [ice] ICE negotiated: local interface 195.216.147.147 Aug 8 10:25:19 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl port 10062]: [ice] ICE negotiated: peer for component 2 is 188.23.81.254:57650 Aug 8 10:25:19 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl port 10048]: [core] SRTP output wanted, but no crypto suite was negotiated Aug 8 10:25:22 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl port 10048]: [core] Confirmed peer address as 195.216.153.111:17584 Aug 8 10:25:22 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl port 10048]: [core] Kernelizing media stream: 195.216.153.111:17584 -> 195.216.147.147:10048 | 195.216.147.147:10062 -> 188.23.81.254:59760 Aug 8 10:25:22 proxy-01 rtpengine[30571]: WARNING: [qn3csvi7broe24ic19kl port 10048]: [core] No support for kernel packet forwarding available (encryption cipher or HMAC not supported by kernel module) Aug 8 10:25:22 proxy-01 rtpengine[30571]: NOTICE: [qn3csvi7broe24ic19kl port 10048]: [core] Setting 'non-forwarding' flag for kernel stream due to lack of sinks Aug 8 10:25:24 proxy-01 rtpengine[30571]: INFO: [qn3csvi7broe24ic19kl port 10049]: [core] Confirmed peer address as 195.216.153.111:17585 Aug 8 10:25:24 proxy-01 rtpengine[30571]: ERR: [qn3csvi7broe24ic19kl port 10049]: [rtcp] SRTCP output wanted, but no crypto suite was negotiated

The config file looks like this: rtpengine_manage("trust-address replace-origin replace-session-connection rtcp-mux-offer DTLS=passive SDES-off ICE=force RTP/SAVPF")

What do I need to do to fix this? Can anyone help me?

rfuchs commented 2 years ago

That error is coming from OpenSSL. Never seen it before and no idea what it means. What platform is this and what version of OpenSSL?

vadimd333 commented 2 years ago

CentOS Linux release 7.9.2009 (Core)

openssl11-libs-1.1.1k-3.el7.x86_64 openssl-libs-1.0.2k-25.el7_9.x86_64 openssl-1.0.2k-25.el7_9.x86_64

vadimd333 commented 2 years ago

Such SDP in the INVITE (to WebRTC):

v=0 o=- 432994847 432994847 IN IP4 195.216.147.147 s=P2SIP-A c=IN IP4 195.216.147.147 t=0 0 m=audio 10994 RTP/SAVPF 8 0 107 101 a=maxptime:20 a=rtpmap:8 PCMA/8000 a=rtpmap:0 PCMU/8000 a=rtpmap:107 opus/48000/2 a=fmtp:107 useinbandfec=1 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=sendrecv a=rtcp:10995 a=rtcp-mux a=setup:actpass a=fingerprint:sha-256 A1:EF:24:44:02:77:0F:A2:B3:43:83:42:0E:4D:DB:4E:F5:5D:C9:DE:E9:35:EC:12:36:C8:19:6E:34:EF:3B:80 a=ptime:20 a=ice-ufrag:5eELLAg6 a=ice-pwd:7zuWfG3a4C3zbrRkjIow0lVlGw a=candidate:3725PLA4OvYPHqQy 1 UDP 2130706431 195.216.147.147 10994 typ host a=candidate:3725PLA4OvYPHqQy 2 UDP 2130706430 195.216.147.147 10995 typ host

vadimd333 commented 2 years ago

When i try to compile it with openssl-1.1.1k (headers) the following errors appear:

stun.o: In function __integrity': /usr/src/rtpengine/daemon/stun.c:360: undefined reference toHMAC_CTX_new' /usr/src/rtpengine/daemon/stun.c:374: undefined reference to HMAC_CTX_free' crypto.o: In functionhmac_sha1_rtp': /usr/src/rtpengine/daemon/crypto.c:827: undefined reference to HMAC_CTX_new' /usr/src/rtpengine/daemon/crypto.c:839: undefined reference toHMAC_CTX_free' dtls.o: In function cert_init': /usr/src/rtpengine/daemon/dtls.c:311: undefined reference toX509_getm_notBefore' /usr/src/rtpengine/daemon/dtls.c:314: undefined reference to X509_getm_notAfter' dtls.o: In functiondtls_connection_init': /usr/src/rtpengine/daemon/dtls.c:645: undefined reference to SSL_set_options' /usr/src/rtpengine/daemon/dtls.c:651: undefined reference toSSL_CTX_set_options' collect2: ошибка: выполнение ld завершилось с кодом возврата 1 make[2]: [rtpengine] Ошибка 1 rm sdp.strhash.c control_ng.strhash.c call_interfaces.strhash.c janus.strhash.c make[2]: Выход из каталога `/usr/src/rtpengine/daemon' make[1]: [all] Ошибка 2 make[1]: Выход из каталога `/usr/src/rtpengine/daemon' make: *** [all] Ошибка 2

vadimd333 commented 2 years ago

On CentOS 8 it works. But in the log file i find such lines:

Aug 9 16:29:57 proxy-02 rtpengine[58883]: ERR: [dc6308e1-f0b8-42ca-9a13-50463cce7ca6 port 10120]: [core] SRTP output wanted, but no crypto suite was negotiated Aug 9 16:30:54 proxy-02 rtpengine[58883]: ERR: [gpouof7k5st5escn02ah port 10136]: [core] SRTP output wanted, but no crypto suite was negotiated Aug 9 16:30:59 proxy-02 rtpengine[58883]: ERR: [gpouof7k5st5escn02ah port 10137]: [rtcp] SRTCP output wanted, but no crypto suite was negotiated

kietcaodev commented 2 years ago

hello, i have the same error. log below Creating active DTLS connection context ERR: [5cutgkr5cm99p2t0246p]: [crypto] Failed to init DTLS connection: key values mismatch [20509]: DEBUG: [5cutgkr5cm99p2t0246p]: [crypto] Creating active DTLS connection context rtpengine[20509]: ERR: [5cutgkr5cm99p2t0246p]: [crypto] Failed to init DTLS connection: key values mismatch

i use webrtc --> dsiprouter + rtpengine --> asterisk openssl version 1.1.1

ChrisZhangJin commented 1 year ago

i encounted the same issue... can anyone help?

ChrisZhangJin commented 1 year ago

i encounted the same issue... can anyone help?

I just figured it out. please check this post for reference.

https://stackoverflow.com/questions/74496994/rtpenginefailed-to-init-dtls-connection-key-values-mismatch

Hope it could help.

rfuchs commented 1 year ago

Thanks for the update. Closing this issue then. Perhaps older OpenSSL versions don't like the EC-based certificates.

pwakano commented 1 year ago

Hi @rfuchs , sorry to post on this closed ticket, but I just started having this exact issue after upgrading rtpengine from 8.5.2.7 to 10.5.3.6. I'm on centos 7 and openssl 1.0.2k, this problem doesn't happen with version 8.5.2.7 but happens if I upgrade to the 10.5.3.6, would you possibly know what has changed in rtpengine that now causes this issue? You mentioned "Perhaps older OpenSSL versions don't like the EC-based certificates.", so is now RTPengine using EC certificates instead of the RSA ones?

pwakano commented 1 year ago

I found I can change the dtls-cert-cipher to rsa, then the key mismatch error is gone. However, it started giving the error described here https://github.com/sipwise/rtpengine/issues/1210