Skip to content

Conversation

@alicefr
Copy link
Contributor

@alicefr alicefr commented Aug 28, 2025

Create first version of the pin.
The test.sh script tries to encrypt and unlock a device and can be used for some manual testing.
In order to perform the encryption, you need to have trustee running and set its url in the data.json. Additionally, you also need to upload the secret, and you can use the test-secret-trustee as example.
I have uploaded the secret using the kbs-client from trustee:

$ target/debug/kbs-client --url http://localhost:8080  config --auth-private-key kbs/config/private.key  set-resource --path conf-cluster/root/machine --resource-file test-secret-trustee

Clevis expect to have the encrypt and decrypt scripts, so I have created those scripts in my local enviroment:

cat /usr/local/sbin/clevis-encrypt-trustee
#!/bin/bash

/home/afrosi/src/clevis-pin-trustee/target/debug/clevis-pin-trustee encrypt "$@"

and

cat /usr/local/sbin/clevis-decrypt-trustee
#!/bin/bash

/home/afrosi/src/clevis-pin-trustee/target/debug/clevis-pin-trustee decrypt "$@"

Clevis looks for the scripts automatically based on the name of the pin

src/main.rs Outdated
resource_tag: &str,
) -> Result<String> {
//let output = StdCommand::new("trustee-attester")
let output = StdCommand::new("/home/afrosi/src/trustee/target/debug/kbs-client")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

need to fix this

Copy link
Member

@travier travier left a comment

Choose a reason for hiding this comment

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

Not tested but looking good. Comments can be addressed as a follow up PR as well. Let's not forget to add a LICENSE to this repo immediately as well.

data.json Outdated
Comment on lines 3 to 4
"resource_repository": "conf-cluster",
"resource_type": "root"
Copy link
Member

Choose a reason for hiding this comment

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

We can probably have only one "path" variable here and have the logic of figuring out what is in there be in another tool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I split it because of the tag/id, this needs to be part of the path as well, so would you prefer to have a partial path here?

src/main.rs Outdated
}

fn main() -> Result<()> {
let matches = Command::new("clevis-pin-trustee")
Copy link
Member

Choose a reason for hiding this comment

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

You can use the derive pattern with structures to make this easier to read. See https://github.com/confidential-clusters/compute-pcrs/blob/main/cli/src/main.rs#L10 for an example.

Copy link

@sarroutbi sarroutbi left a comment

Choose a reason for hiding this comment

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

In general, changes LGTM. The only comment is that the logic for fetching the key, decoding it, and creating a Jwk is nearly identical in both the encrypt and decrypt functions.

You might create a helper function to handle this logic

Containerize the build of the pin.

Signed-off-by: Alice Frosi <[email protected]>
@alicefr
Copy link
Contributor Author

alicefr commented Sep 3, 2025

@travier @uril as far as I understand we need to pass to the trustee-agent the certificate for the trustee sever, am I right? If so, don't we need here an array of certificates like for the urls? If so, then I would merge the urls together with the certificate for the pin configuration. Like:

{
  "servers": [
      {
         "url": "http://trustee1:8080",
          "cert": "",
      },
      {
         "url": "http://trustee2:8080",
          "cert": "",
      },   
  ],
  "resource_path": "conf-cluster/<id>/root",
}

@alicefr
Copy link
Contributor Author

alicefr commented Sep 3, 2025

The pin configuration depends on the discussion in coreos/ignition#2099

@uril
Copy link

uril commented Sep 3, 2025

@alicefr Yes, we do want a list of (KBSURL, https-certificate).

@uril
Copy link

uril commented Sep 3, 2025

Nice ! I added some minor comments.

@alicefr alicefr force-pushed the initial-commit branch 2 times, most recently from 53671e6 to 5f76990 Compare September 9, 2025 13:40
Copy link
Member

@travier travier left a comment

Choose a reason for hiding this comment

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

Looking good. Some nits but we can also fix them later

@@ -0,0 +1,10 @@
FROM docker.io/library/rust:trixie as build
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 use a Fedora image here to do the build. We can do what we did in compure-pcrs.

@@ -0,0 +1,3 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

Hum, why do we need that? Let's place the binaries in the right place directly?

Comment on lines +135 to +136
const MAX_ATTEMPTS: u32 = 3;
const DELAY: Duration = Duration::from_secs(5);
Copy link
Member

Choose a reason for hiding this comment

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

This is fine for now but we'll need to make this either bigger or configurable.

Copy link
Member

@travier travier left a comment

Choose a reason for hiding this comment

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

Let's start with that and we'll iterate

@travier travier merged commit 23a7988 into latchset:main Sep 16, 2025
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.

4 participants