From e457e43836b2790d5062e589b105f867ecfcfbf0 Mon Sep 17 00:00:00 2001 From: Joachim Reiersen Date: Fri, 21 Oct 2022 12:08:22 -0700 Subject: [PATCH] Fix bug where RTCTransportStats.dtlsCipher was missing when using OpenSSL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A bug in the id being searched for inside OpenSSLStreamAdapter::SslCipherSuiteToName prevented the lookup from ever succeeding. This resulted in this stat being unavailable when calling PeerConnection::GetStats(). To fix the problem, look for (0x03000000L | cipher_suite) which matches what the BoringSSL codepath is doing. Bug: webrtc:14596 Change-Id: Ic36d77dbc4c2378fbde1e2f21a9f5bd735b36741 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280100 Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Reviewed-by: Henrik Boström Cr-Commit-Position: refs/heads/main@{#38460} --- AUTHORS | 1 + rtc_base/openssl_stream_adapter.cc | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index a0632d20fa..7506cba09e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -146,6 +146,7 @@ HyperConnect Inc. <*@hpcnt.com> Intel Corporation <*@intel.com> LG Electronics, Inc. <*@lge.com> Life On Air Inc. <*@lifeonair.com> +Meta Platforms, Inc. <*@meta.com> Microsoft Corporation <*@microsoft.com> MIPS Technologies <*@mips.com> Mozilla Foundation <*@mozilla.com> diff --git a/rtc_base/openssl_stream_adapter.cc b/rtc_base/openssl_stream_adapter.cc index da484ad3bf..61bf6743d6 100644 --- a/rtc_base/openssl_stream_adapter.cc +++ b/rtc_base/openssl_stream_adapter.cc @@ -390,9 +390,10 @@ std::string OpenSSLStreamAdapter::SslCipherSuiteToName(int cipher_suite) { } return SSL_CIPHER_standard_name(ssl_cipher); #else + const int openssl_cipher_id = 0x03000000L | cipher_suite; for (const SslCipherMapEntry* entry = kSslCipherMap; entry->rfc_name; ++entry) { - if (cipher_suite == static_cast(entry->openssl_id)) { + if (openssl_cipher_id == static_cast(entry->openssl_id)) { return entry->rfc_name; } }