diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 6f98111af73..ee1e9cdf49d 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -2962,7 +2962,7 @@ bool SecurityManager::discovered_reader( if (local_writer != writer_handles_.end()) { - if (remote_participant_crypto_handle != nullptr) + if (remote_participant_crypto_handle != nullptr && shared_secret_handle != nullptr) { DatareaderCryptoHandle* remote_reader_handle = crypto_plugin_->cryptokeyfactory()->register_matched_remote_datareader( @@ -3328,7 +3328,7 @@ bool SecurityManager::discovered_writer( if (local_reader != reader_handles_.end()) { - if (remote_participant_crypto_handle != nullptr) + if (remote_participant_crypto_handle != nullptr && shared_secret_handle != nullptr) { DatawriterCryptoHandle* remote_writer_handle = crypto_plugin_->cryptokeyfactory()->register_matched_remote_datawriter(