-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add nebula_ca plugin #539
base: main
Are you sure you want to change the base?
Add nebula_ca plugin #539
Conversation
4359304
to
a48c6de
Compare
This PR is ready for review. I updated the PR description with the steps to build and test it. |
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.
lgtm
I reviewed this by going through the code and looking for bugs -- I didn't spot anything.
I also tried to build and run. docker compose up
fails for me but for reasons unrelated to your work, I think. If you eventually lift those instructions and put them in docs or a tutorial, we can add some more details.
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.
Looks clean. A few suggestions but nothing too significant.
cc40b9a
to
604a793
Compare
All feedbacks applied and added some improvements
|
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.
LGTM
There is small problem with link checker.
Let's get another approval from @confidential-containers/trustee-maintainers
This plugin calls the nebula-cert binary to provide some of its functionality for Nebula nodes (e.g. CoCo PODs or confidential VMs) that want to join an encrypted Nebula overlay network (ENON). The Nebula CA is created when the KBS is started. Currently, the only runtime service it provides is the credential service which returns the following structure for the caller to join an ENON. struct CredentialServiceOut { node_crt: Vec<u8>, // Self-signed certificate created node_key: Vec<u8>, // Key created ca_crt: Vec<u8>, // CA certificate } Since the CredentialServiceOut is returned only after the caller is attested, the ENON is expected to have only attested nodes. Some use cases for an ENON: - The workload does not trust the network interface provided by the CSP - The workload does not support data encryption over the network For further information on configuration or usage, please refer to the kbs/docs/plugins/nebula_ca.md or the official Nebula website https://github.com/slackhq/nebula Signed-off-by: Claudio Carvalho <[email protected]>
604a793
to
49ed388
Compare
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.
Thanks for the dry code.
There is a question about the design. Do you think it better for users to manually generate the nebula certs out of band instead of generate them automatically inside code?
Users might reuse some certs for deployments rather than generate them during each deployment.
@@ -283,6 +316,13 @@ policy_engine = "opa" | |||
name = "resource" | |||
type = "LocalFs" | |||
dir_path = "/opt/confidential-containers/kbs/repository" | |||
|
|||
[[plugins]] |
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.
Shall we add a separate config example for nebula and leave this only for CoCoAS example?
nebula_cert_bin_path = "/usr/local/bin/nebula-cert" | ||
work_dir = "/opt/confidential-containers/kbs/nebula-ca" | ||
[plugins.settings] | ||
name = "Nebula CA for Trustee KBS" |
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.
Same suggestion as before.
/// Nebula CA plugin. | ||
/// More information can be found in the KBS plugin documentation | ||
/// and in the [Nebula](https://github.com/slackhq/nebula) website. |
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.
We could use inner line doc here.
/// Nebula CA plugin. | |
/// More information can be found in the KBS plugin documentation | |
/// and in the [Nebula](https://github.com/slackhq/nebula) website. | |
//! Nebula CA plugin. | |
//! More information can be found in the KBS plugin documentation | |
//! and in the [Nebula](https://github.com/slackhq/nebula) website. |
An Example
If we publish kbs to crates.io
Behavior: https://github.com/serde-rs/serde/blob/master/serde/src/ser/mod.rs
Source code: https://github.com/serde-rs/serde/blob/master/serde/src/ser/mod.rs
"1.2.3.5/21,1.2.3.6/21".into(), | ||
]) | ||
)] | ||
|
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 delete the empty line
.await | ||
.context(format!("{} sign {:?}", self.path.display(), &args))?; | ||
if !status.success() { | ||
return Err(anyhow!("{} sign {:?}", self.path.display(), &args)); |
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.
return Err(anyhow!("{} sign {:?}", self.path.display(), &args)); | |
bail!("{} sign {:?}", self.path.display(), &args); |
.status() | ||
.context(format!("{} verify {:?}", self.path.display(), &args))?; | ||
if !status.success() { | ||
return Err(anyhow!("{} verify {:?}", self.path.display(), &args)); |
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.
return Err(anyhow!("{} verify {:?}", self.path.display(), &args)); | |
bail!("{} verify {:?}", self.path.display(), &args); |
ffi::OsString, | ||
fs, | ||
path::{Path, PathBuf}, | ||
process::Command, |
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.
How about using tokio:: process::Command
here? The async version has better efficiency. https://docs.rs/tokio/1.43.0/tokio/process/index.html
You're thinking there's a pool of certs, for example, that you draw from whenever a pod tries to join the network? |
@portersrc I mean only the CA cert, not the node certs |
@cclaudio has some logic related to this (nebula_ca.rs line 125).
And after browsing more, I see he mentions it in the config.md:
He'd have to comment on how the user is expected to do this, though. I assume they rebuild the container with those CA files included. It might be good to document how to generate and then include them. |
This PR adds the nebula_ca plugin.
How to build and start the plugin
Build trustee with the 'nebula-ca-plugin' cargo feature enabled and build a KBS image that has the nebula-cert binary
Add the lines below to
kbs/config/docker-compose/kbs-config.toml
Start trustee
How to test the credential service
Ultimately, the plugin will be called from the CDH (confidential-containers/guest-components#763). In the meantime, we can build and use the kbs-client I have in the branch https://github.com/cclaudio/trustee/tree/nebula-ca-plugin-test
Request a Nebula credential
That should return a CredentialServiceOut structure like: