mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
20230628 tpm minor issue with key regen (#1790)
* Ignore key that cant be loaded * fix handle
This commit is contained in:
parent
69dfea3601
commit
b752ab65b8
|
@ -830,20 +830,22 @@ pub(crate) mod tpm {
|
||||||
|
|
||||||
let ex_ctx = if let Some(ctx_data) = ctx_data {
|
let ex_ctx = if let Some(ctx_data) = ctx_data {
|
||||||
// Test loading, blank it out if it fails.
|
// Test loading, blank it out if it fails.
|
||||||
// deserialise
|
serde_json::from_slice(ctx_data.as_slice()).map_err(|e| {
|
||||||
let maybe_ctx: TpmsContext =
|
|
||||||
serde_json::from_slice(ctx_data.as_slice()).map_err(|e| {
|
|
||||||
warn!("json error -> {:?}", e);
|
warn!("json error -> {:?}", e);
|
||||||
})?;
|
})
|
||||||
|
// On error, becomes none and we do nothing else.
|
||||||
// can it load?
|
.ok()
|
||||||
context
|
.and_then(|maybe_ctx: TpmsContext| {
|
||||||
.execute_with_nullauth_session(|ctx| ctx.context_load(maybe_ctx.clone()))
|
// can it load?
|
||||||
.map_err(|e| {
|
context
|
||||||
error!(tpm_err = ?e, "Failed to load tpm context");
|
.execute_with_nullauth_session(|ctx| ctx.context_load(maybe_ctx.clone()))
|
||||||
})?;
|
.map_err(|e| {
|
||||||
|
error!(tpm_err = ?e, "Failed to load tpm context");
|
||||||
Some(maybe_ctx)
|
})
|
||||||
|
.ok()
|
||||||
|
// It loaded, so sub in our context.
|
||||||
|
.map(|_handle| maybe_ctx)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue