diff --git a/pkcs11/src/config/initialization.rs b/pkcs11/src/config/initialization.rs index b156b824..a10b6d3d 100644 --- a/pkcs11/src/config/initialization.rs +++ b/pkcs11/src/config/initialization.rs @@ -27,6 +27,8 @@ pub enum InitializationError { NoCerts, #[error("No operator or administrator for slot: {0}")] NoUser(String), + #[error("No instance given for a slot")] + NoInstance, } pub fn initialize_with_configs( @@ -288,7 +290,11 @@ fn slot_from_config(slot: &SlotConfig) -> Result { }; Ok(api_config) }) - .collect::>()?; + .collect::, InitializationError>>()?; + if instances.is_empty() { + error!("Slot without any instance configured"); + return Err(InitializationError::NoInstance); + } Ok(Slot { _description: slot.description.clone(),