Skip to content

Commit

Permalink
feat: update nethsm sdk version
Browse files Browse the repository at this point in the history
  • Loading branch information
nponsard committed Sep 28, 2023
1 parent 8ece985 commit 70fd45b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkcs11/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ serde = { version = "1", features = ["derive"], default-features = false }
serde_yaml = "0.9.22"
serde_json = { default-features = false, version = "1.0.64" }
lazy_static = "1.4.0"
nethsm-sdk-rs = { version = "0.4.0" }
nethsm-sdk-rs = { version = "0.5" }
rustls = { version = "0.21", features = [
"dangerous_configuration",
], default-features = false }
Expand Down
12 changes: 11 additions & 1 deletion pkcs11/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub enum ApiError {
Io(std::io::Error),
ResponseError(ResponseContent),
NoInstance,
StringParse(std::string::FromUtf8Error),
}

impl<T> From<apis::Error<T>> for ApiError {
Expand All @@ -49,8 +50,15 @@ impl<T> From<apis::Error<T>> for ApiError {
apis::Error::Io(e) => ApiError::Io(e),
apis::Error::ResponseError(resp) => ApiError::ResponseError(ResponseContent {
status: resp.status,
content: resp.content,
content: String::from_utf8(resp.content).unwrap_or_else(|e| {
format!(
"Unable to parse response content into string: {:?}",
e.as_bytes()
);
String::default()
}),
}),
apis::Error::StringParse(e) => ApiError::StringParse(e),
}
}
}
Expand Down Expand Up @@ -144,6 +152,7 @@ impl From<Error> for CK_RV {
412 => CKR_TOKEN_NOT_PRESENT,
_ => CKR_DEVICE_ERROR,
},
ApiError::StringParse(_) => CKR_DEVICE_ERROR,
},
}
}
Expand Down Expand Up @@ -195,6 +204,7 @@ impl std::fmt::Display for Error {
412 => "The NetHSM is not set up properly".to_string(),
_ => format!("Api error: {:?}", resp),
},
ApiError::StringParse(err) => format!("String parse error: {:?}", err),
},
Error::Base64Error(err) => format!("Base64 Decode error: {:?}", err),
Error::StringParse(err) => format!("String parse error: {:?}", err),
Expand Down

0 comments on commit 70fd45b

Please sign in to comment.