I'm looking into tuf/rust-tuf for some update procedures.
For now I'm failing to create a minimal working example and I'm not sure if it's just me or if there is a bug in the documentation that needs fixing. rust-tuf's src/lib.rs contains an example with a function get_original_root()
that simply is unimplemented!()
. I'm trying to fill the gap here.
First, I have followed the TUF documentation to generate a directory structure to be served according to the documentation in https://github.com/theupdateframework/tuf/blob/develop/tuf/README.md. In a nutshell, the steps are:
- Generate RSA keys (root, targets, snapshot, timestamp);
- Create repository metadata;
- Create the actual repository.
Step 1. is trivial, simply calling tuf.repository_tool.generate_and_write_rsa_keypair()
for each key. Step 2. uses create_new_repository()
and adds the keys to the repo. Step 3. walks the repository directory and signs files using add_targets()
.
The problem I am facing comes from the call to rust-tuf's tuf::interchange::JsonDataInterchange::from_reader()
. Since the get_original_root()
function in unimplemented!()
, I had to adapt it. It's returning a File
, so I let it return File::open("repository/metadata/root.json").unwrap()
where the json file was created by step 3 above. The from_reader()
call fails though with a deserialization error:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Encoding("JSON: ErrorImpl { code: Message(\"missing field `key_id`\"), line: 7, column: 3 }")', src/libcore/result.rs:859
I checked the files generated by tuf.repository_tool
, and none contains the string key_id
. The rust-tuf struct Signature
seems to have one such field and is Deserialize
so maybe this is where the error comes from?
I might be loading the improper file in tuf::interchange::JsonDataInterchange::from_reader()
, but then there is no file that contains the key_id
field in tuf's generated files. Am I following the proper guide to initialize a repository (https://github.com/theupdateframework/tuf/blob/develop/tuf/README.md)?
Note that I'm using rust-tuf c3321bf1295be66df46dcfb0440df491f2cf583f (branch develop
) and tuf 904fa9b8df8ab8c632a210a2b05fd741e366788a (branch develop
).
Thanks!
Priority :: Medium Feature :: Improvement