fix: master-key: upload RSA encoded key with backup

When uploading an RSA encoded key alongside the backup,
the backup would fail with the error message: "wrong blob
file extension".
Adding the '.blob' extension to rsa-encrypted.key before the
the call to upload_blob_from_data(), rather than after, fixes
the issue.

Signed-off-by: Dylan Whyte <d.whyte@proxmox.com>
This commit is contained in:
Dylan Whyte 2020-08-06 09:13:40 +02:00 committed by Dietmar Maurer
parent d74edc3d89
commit 5f76ac37b5

View File

@ -1120,12 +1120,12 @@ async fn create_backup(
} }
if let Some(rsa_encrypted_key) = rsa_encrypted_key { if let Some(rsa_encrypted_key) = rsa_encrypted_key {
let target = "rsa-encrypted.key"; let target = "rsa-encrypted.key.blob";
println!("Upload RSA encoded key to '{:?}' as {}", repo, target); println!("Upload RSA encoded key to '{:?}' as {}", repo, target);
let stats = client let stats = client
.upload_blob_from_data(rsa_encrypted_key, target, false, false) .upload_blob_from_data(rsa_encrypted_key, target, false, false)
.await?; .await?;
manifest.add_file(format!("{}.blob", target), stats.size, stats.csum, crypt_mode)?; manifest.add_file(target.to_string(), stats.size, stats.csum, crypt_mode)?;
// openssl rsautl -decrypt -inkey master-private.pem -in rsa-encrypted.key -out t // openssl rsautl -decrypt -inkey master-private.pem -in rsa-encrypted.key -out t
/* /*
@ -1136,7 +1136,6 @@ async fn create_backup(
println!("TEST {} {:?}", len, buffer2); println!("TEST {} {:?}", len, buffer2);
*/ */
} }
// create manifest (index.json) // create manifest (index.json)
// manifests are never encrypted, but include a signature // manifests are never encrypted, but include a signature
let manifest = manifest.to_string(crypt_config.as_ref().map(Arc::as_ref)) let manifest = manifest.to_string(crypt_config.as_ref().map(Arc::as_ref))