diff --git a/mls_validation_service/src/handlers.rs b/mls_validation_service/src/handlers.rs index 448b483df..98d3528e3 100644 --- a/mls_validation_service/src/handlers.rs +++ b/mls_validation_service/src/handlers.rs @@ -1,4 +1,4 @@ -use openmls::prelude::{MlsMessageIn, ProtocolMessage, TlsDeserializeTrait}; +use openmls::{credentials::BasicCredential, prelude::{tls_codec::Deserialize, MlsMessageIn, ProtocolMessage}}; use openmls_rust_crypto::RustCrypto; use tonic::{Request, Response, Status}; @@ -86,9 +86,11 @@ struct ValidateGroupMessageResult { fn validate_group_message(message: Vec) -> Result { let msg_result = MlsMessageIn::tls_deserialize(&mut message.as_slice()) - .map_err(|_| "failed to decode".to_string())?; + .map_err(|e| e.to_string())?; - let protocol_message: ProtocolMessage = msg_result.into(); + // EM: Fix Error Handling + let protocol_message: ProtocolMessage = msg_result.try_into_protocol_message() + .map_err(|e| e.to_string())?; Ok(ValidateGroupMessageResult { group_id: serialize_group_id(protocol_message.group_id().as_slice()), @@ -108,15 +110,18 @@ fn validate_key_package(key_package_bytes: Vec) -> Result) -> Result Result { - let mut mls_group = - OpenMlsGroup::new_from_welcome(provider, &build_group_join_config(), welcome, None)?; - mls_group.save(provider.key_store())?; - let group_id = mls_group.group_id().to_vec(); + let mut mls_welcome = + // EM: Fix error handling here + StagedWelcome::new_from_welcome(provider, &build_group_join_config(), welcome, None) + .expect("Error creating staged join from Welcome") + .into_group(provider) + .expect("Error creating group from staged join"); + + mls_welcome.save(provider.key_store())?; + let group_id = mls_welcome.group_id().to_vec(); let to_store = StoredGroup::new(group_id, now_ns(), GroupMembershipState::Pending); let stored_group = provider.conn().insert_or_ignore_group(to_store)?;