tuftool: bug when using path as URL
webern opened this issue · comments
Matthew James Briggs commented
A bug was introduced in this commit 55a40cc
These lines do not work for tuftool gen rsa-key
because the path to the key is for a file that does not yet exist. So we end up parsing the filepath with Url which fails like this:
let input_as_path = Path::new(input);
let url = if input_as_path.exists() {
Url::from_file_path(input)
.ok() // dump unhelpful `()` error
.context(error::FileUrlSnafu {
path: input_as_path.to_owned(),
})?
} else {
Url::parse(input).context(error::UrlParseSnafu { url: input })?
};
$ dir=/tmp/url-bug
rm -rf $dir
mkdir $dir
tuftool root init $dir/root.json
tuftool root gen-rsa-key \
$dir/root.json \
$dir/default.pem \
--role root --role snapshot --role targets --role timestamp
Output:
Failed to parse URL "/tmp/url-bug/default.pem": relative URL without a base