Skip to content

Config security using enclave ROS argument#412

Draft
ahcorde wants to merge 6 commits intorollingfrom
ahcorde/rolling/secutiry
Draft

Config security using enclave ROS argument#412
ahcorde wants to merge 6 commits intorollingfrom
ahcorde/rolling/secutiry

Conversation

@ahcorde
Copy link
Contributor

@ahcorde ahcorde commented Jan 10, 2025

As I mentioned in this other PR #411 (comment) we should be able to configure the security features using --ros-args --enclave <enclave name>.

This PR drafted the required changes in the code to be able to set them, note that the Zenoh Config should be configure before the session is created.

What do you think about the changes?

Another question, Up to this point, we only supported one kind of rmw: DDS, we are using a package called rmw_dds_common to get the certificates, etc, in this package which is not DDS based. I know it's just a naming thing, but do we need to create a more generic package name and move some stuff there? @clalancette @Yadunund ?

Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde ahcorde self-assigned this Jan 10, 2025
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde ahcorde mentioned this pull request Jan 29, 2025
Copy link
Member

@Yadunund Yadunund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! Please find my feedback below.

Also, my preference is to not merge this PR while it still depends on rmw_dds_common. We only need one function from that library and I don't think we need to add a dependency for that reason especially since rmw_sercurity_common is in the works. Semantically, it also does not make sense for this middleware to depend on a DDS package. I see two paths forward:

  1. Get rmw_sercurity_common merged upstream, backport that merge to Jazzy atleast, and release binaries for the package on Rolling and Jazzy. Then merge #434 into this one.
  2. Temporarily copy in the definition and implementation of rmw_dds_common::get_security_files into this repo and use the function without linking depending on rmw_dds_common.

Personally I think we should do 2) first (in this PR) and then when 1) is ready, delete the internal get_security_files and switch to the one in rmw_security_common.

find_package(zenoh_cpp_vendor REQUIRED)

if(SECURITY)
find_package(OpenSSL REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see OpenSSL being linked anywhere? Does this happen transitively via rmw_dds_common::rmw_dds_common_library?


if(SECURITY)
find_package(OpenSSL REQUIRED)
set(HAVE_SECURITY 1)
Copy link
Member

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_options is present in rmw_context_impl_s.

std::size_t domain_id,
const std::string & enclave)
const std::string & enclave,
const rmw_security_options_t * security_options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const rmw_security_options_t * security_options)
const rmw_security_options_t & security_options)

#ifdef HAVE_SECURITY
std::unordered_map<std::string, std::string> security_files_paths;
if (rmw_dds_common::get_security_files(
true, "", security_options->security_root_path, security_files_paths))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
true, "", security_options->security_root_path, security_files_paths))
true, "", security_options.security_root_path, security_files_paths))

throw std::runtime_error("Error configuring Zenoh session.");
}

#ifdef HAVE_SECURITY
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this flag? My understanding is that rmw_dds_common::get_security_files will return false if the enclave ROS arg is not passed or is invalid so we can have this codeblock that modifies for all situations. Let me know if I misunderstood something.

Comment on lines +88 to +92
"\t\t\t\t\"root_ca_certificate\": \"" + security_files_paths["IDENTITY_CA"] + "\",\n" +
"\t\t\t\t\"listen_private_key\": \"" + security_files_paths["PRIVATE_KEY"] + "\",\n" +
"\t\t\t\t\"listen_certificate\": \"" + security_files_paths["CERTIFICATE"] + "\",\n" +
"\t\t\t\t\"connect_private_key\": \"" + security_files_paths["PRIVATE_KEY"] + "\",\n" +
"\t\t\t\t\"connect_certificate\": \"" + security_files_paths["CERTIFICATE"] + "\",\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check that these keys exist in security_files_paths before accessing their values. If not present, return an error.

const std::size_t domain_id,
const std::string & enclave)
const std::string & enclave,
const rmw_security_options_t * security_options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const rmw_security_options_t * security_options)
const rmw_security_options_t & security_options)

const std::size_t domain_id,
const std::string & enclave);
const std::string & enclave,
const rmw_security_options_t * security_options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const rmw_security_options_t * security_options);
const rmw_security_options_t & security_options);

context->actual_domain_id,
std::string(options->enclave)
std::string(options->enclave),
&context->options.security_options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&context->options.security_options
context->options.security_options

mjcarroll and others added 2 commits April 4, 2025 18:52
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
* Use rmw_security_common package

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>

* use rmw_security_common

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>

* Feedback

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>

---------

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
Co-authored-by: Michael Carroll <mjcarroll@intrinsic.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants