Skip to content

Commit 5064b0b

Browse files
Merge pull request #1154 from dmllr/master
Fix MbedTLS usage bugs and allow cmake to use imported mbedtls library
2 parents fbd8f23 + 3b3a61d commit 5064b0b

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,9 @@ else()
342342
target_link_libraries(datachannel PRIVATE libSRTP::srtp2)
343343
target_link_libraries(datachannel-static PRIVATE libSRTP::srtp2)
344344
else()
345-
add_subdirectory(deps/libsrtp EXCLUDE_FROM_ALL)
345+
if(NOT TARGET srtp2)
346+
add_subdirectory(deps/libsrtp EXCLUDE_FROM_ALL)
347+
endif()
346348
target_compile_definitions(datachannel PRIVATE RTC_SYSTEM_SRTP=0)
347349
target_compile_definitions(datachannel-static PRIVATE RTC_SYSTEM_SRTP=0)
348350
target_link_libraries(datachannel PRIVATE srtp2)
@@ -371,7 +373,9 @@ if (USE_GNUTLS)
371373
target_link_libraries(datachannel-static PRIVATE Nettle::Nettle)
372374
endif()
373375
elseif(USE_MBEDTLS)
374-
find_package(MbedTLS 3 REQUIRED)
376+
if(NOT TARGET MbedTLS::MbedTLS)
377+
find_package(MbedTLS 3 REQUIRED)
378+
endif()
375379
target_compile_definitions(datachannel PRIVATE USE_MBEDTLS=1)
376380
target_compile_definitions(datachannel-static PRIVATE USE_MBEDTLS=1)
377381
target_link_libraries(datachannel PRIVATE MbedTLS::MbedTLS)

examples/streamer/h264fileparser.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ void H264FileParser::loadNextSample() {
5050
}
5151
}
5252

53-
vector<byte> H264FileParser::initialNALUS() {
54-
vector<byte> units{};
53+
vector<std::byte> H264FileParser::initialNALUS() {
54+
vector<std::byte> units{};
5555
if (previousUnitType7.has_value()) {
5656
auto nalu = previousUnitType7.value();
5757
units.insert(units.end(), nalu.begin(), nalu.end());

src/impl/tls.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ bool check(int ret, const string &message) {
101101
if (ret < 0) {
102102
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE ||
103103
ret == MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS || ret == MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ||
104-
ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY)
104+
ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY || ret == MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET)
105105
return false;
106106

107107
const size_t bufferSize = 1024;

src/impl/tlstransport.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ TlsTransport::TlsTransport(variant<shared_ptr<TcpTransport>, shared_ptr<HttpProx
323323

324324
PLOG_DEBUG << "Initializing TLS transport (MbedTLS)";
325325

326+
psa_crypto_init();
326327
mbedtls_entropy_init(&mEntropy);
327328
mbedtls_ctr_drbg_init(&mDrbg);
328329
mbedtls_ssl_init(&mSsl);

src/impl/verifiedtlstransport.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ VerifiedTlsTransport::VerifiedTlsTransport(
3636
// *cacert is a PEM content
3737
mbedtls::check(mbedtls_x509_crt_parse(
3838
&mCaCert, reinterpret_cast<const unsigned char *>(cacert->c_str()),
39-
cacert->size()));
39+
cacert->size() + 1));
4040
}
4141
mbedtls_ssl_conf_ca_chain(&mConf, &mCaCert, NULL);
4242
}

0 commit comments

Comments
 (0)