-
Notifications
You must be signed in to change notification settings - Fork 83
Config security using enclave ROS argument #412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ahcorde
wants to merge
6
commits into
rolling
Choose a base branch
from
ahcorde/rolling/secutiry
base: rolling
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1b6cef0
Config security using enclave ROS argument
ahcorde bb0ea22
Merge remote-tracking branch 'origin/rolling' into ahcorde/rolling/se…
ahcorde 62034f9
fill transport/link/tls/
ahcorde f1a1e5c
Merge remote-tracking branch 'origin/rolling' into ahcorde/rolling/se…
ahcorde 1322545
Merge branch 'rolling' into ahcorde/rolling/secutiry
mjcarroll 0cab0b1
Use rmw_security_common package (#434)
ahcorde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ | |
|
|
||
| #include "rcpputils/scope_exit.hpp" | ||
| #include "rmw/error_handling.h" | ||
| #include "rmw_security_common/security.hpp" | ||
| #include "zenoh_utils.hpp" | ||
|
|
||
| // Megabytes of SHM to reserve. | ||
|
|
@@ -52,7 +53,8 @@ class rmw_context_impl_s::Data final : public std::enable_shared_from_this<Data> | |
| // Constructor. | ||
| Data( | ||
| std::size_t domain_id, | ||
| const std::string & enclave) | ||
| const std::string & enclave, | ||
| const rmw_security_options_t & security_options) | ||
| : domain_id_(std::move(domain_id)), | ||
| enclave_(std::move(enclave)), | ||
| is_shutdown_(false), | ||
|
|
@@ -67,7 +69,55 @@ class rmw_context_impl_s::Data final : public std::enable_shared_from_this<Data> | |
| if (!config.has_value()) { | ||
| throw std::runtime_error("Error configuring Zenoh session."); | ||
| } | ||
| #ifdef HAVE_SECURITY | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this flag? My understanding is that |
||
| rcutils_allocator_t allocator = rcutils_get_default_allocator(); | ||
| rcutils_string_map_t security_files = rcutils_get_zero_initialized_string_map(); | ||
| rcutils_ret_t ret = rcutils_string_map_init(&security_files, 0, allocator); | ||
|
|
||
| auto scope_exit = rcpputils::make_scope_exit( | ||
| [&security_files]() { | ||
| rcutils_ret_t ret = rcutils_string_map_fini(&security_files); | ||
| if (ret != RMW_RET_OK) { | ||
| throw std::runtime_error("Failed to fini string map for security."); | ||
| } | ||
| }); | ||
|
|
||
| if (ret != RMW_RET_OK) { | ||
| throw std::runtime_error("Failed to initialize string map for security."); | ||
| } | ||
|
|
||
| if (get_security_files_support_pkcs( | ||
| false, "", security_options.security_root_path, &security_files) == RMW_RET_OK) | ||
| { | ||
| config.value().insert_json5("connect/endpoints", "[\"tls/localhost:7447\"]"); | ||
| config.value().insert_json5("listen/endpoints", "[\"tls/localhost:0\"]"); | ||
|
|
||
| std::string tls_config = "{\"link\": \n" | ||
| "\t\t{ \n" | ||
| "\t\t\t\"protocols\": [ \n" | ||
| "\t\t\t\t\"tls\" \n" | ||
| "\t\t\t], \n" | ||
| "\t\t\t\"tls\": { \n" | ||
| "\t\t\t\t\"enable_mtls\": true, \n" | ||
| "\t\t\t\t\"verify_name_on_connect\": false, \n" | ||
| "\t\t\t\t\"root_ca_certificate\": \"" + std::string(rcutils_string_map_get(&security_files, | ||
| "IDENTITY_CA")) + "\",\n" + | ||
| "\t\t\t\t\"listen_private_key\": \"" + std::string(rcutils_string_map_get(&security_files, | ||
| "PRIVATE_KEY")) + "\",\n" + | ||
| "\t\t\t\t\"listen_certificate\": \"" + std::string(rcutils_string_map_get(&security_files, | ||
| "CERTIFICATE")) + "\",\n" + | ||
| "\t\t\t\t\"connect_private_key\": \"" + std::string(rcutils_string_map_get(&security_files, | ||
| "PRIVATE_KEY")) + "\",\n" + | ||
| "\t\t\t\t\"connect_certificate\": \"" + std::string(rcutils_string_map_get(&security_files, | ||
| "CERTIFICATE")) + "\",\n" + | ||
| "\t\t\t}, \n" | ||
| "\t\t}, \n" | ||
| "\t}\n"; | ||
| config.value().insert_json5( | ||
| "transport", | ||
| tls_config); | ||
| } | ||
| #endif | ||
| zenoh::ZResult result; | ||
|
|
||
| #ifndef _MSC_VER | ||
|
|
@@ -100,8 +150,8 @@ class rmw_context_impl_s::Data final : public std::enable_shared_from_this<Data> | |
| constexpr int64_t ticks_between_print(std::chrono::milliseconds(1000) / sleep_time); | ||
| do { | ||
| zenoh::ZResult result; | ||
| const auto zids = this->session_->get_routers_z_id(&result); | ||
| if (result == Z_OK && !zids.empty()) { | ||
| this->session_->get_routers_z_id(&result); | ||
| if (result == Z_OK) { | ||
| break; | ||
| } | ||
| if ((connection_attempts % ticks_between_print) == 0) { | ||
|
|
@@ -441,9 +491,10 @@ class rmw_context_impl_s::Data final : public std::enable_shared_from_this<Data> | |
| ///============================================================================= | ||
| rmw_context_impl_s::rmw_context_impl_s( | ||
| const std::size_t domain_id, | ||
| const std::string & enclave) | ||
| const std::string & enclave, | ||
| const rmw_security_options_t & security_options) | ||
| { | ||
| data_ = std::make_shared<Data>(domain_id, std::move(enclave)); | ||
| data_ = std::make_shared<Data>(domain_id, std::move(enclave), security_options); | ||
| data_->init(); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not have any special build flags for security. We will overwrite the Zenoh config with auth params if
security_optionsis present inrmw_context_impl_s.