Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

fix: add more debug information when using keyprovider #56

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ctr = { version = ">=0.9", optional = true }
hmac = { version = ">=0.12", optional = true }
josekit = { version = ">=0.7", optional = true }
lazy_static = ">=1.4"
log = "0.4.17"
openssl = { version = ">=0.10", features = ["vendored"], optional = true }
pin-project-lite = { version = "0.2.9", optional = true }
protobuf = { version = "3.2.0", optional = true }
Expand Down
15 changes: 12 additions & 3 deletions src/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::collections::HashMap;
use std::io::Read;

use anyhow::{anyhow, Result};
use log::warn;

use crate::blockcipher::{
EncryptionFinalizer, LayerBlockCipherHandler, LayerBlockCipherOptions,
Expand Down Expand Up @@ -187,9 +188,17 @@ pub fn decrypt_layer_key_opts_data(
priv_key_given = true;
}

if let Ok(opts_data) = pre_unwrap_key(keywrapper, dc, &b64_annotation) {
if !opts_data.is_empty() {
return Ok(opts_data);
match pre_unwrap_key(keywrapper, dc, &b64_annotation) {
Ok(opts_data) => {
if !opts_data.is_empty() {
return Ok(opts_data);
}

warn!("Get empty opts data when unwraping key from keyprovider {scheme}");
continue;
}
Err(e) => {
warn!("Error occurs when unwraping key from keyprovider: {e}");
}
}
// try next keywrapper
Expand Down
4 changes: 2 additions & 2 deletions src/keywrap/keyprovider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ impl KeyProviderKeyWrapper {
});
match handler.join() {
Ok(Ok(v)) => Ok(v),
Ok(Err(e)) => bail!("failed to unwrap key by gRPC, {e}"),
Err(e) => bail!("failed to unwrap key by gRPC, {e:?}"),
Ok(Err(e)) => bail!("failed to unwrap key by ttrpc, {e}"),
Err(e) => bail!("failed to unwrap key by ttrpc, {e:?}"),
}
}
}
Expand Down