diff --git a/xmtp_mls/src/storage/encrypted_store/mod.rs b/xmtp_mls/src/storage/encrypted_store/mod.rs index 61522bd7a..22d3ab145 100644 --- a/xmtp_mls/src/storage/encrypted_store/mod.rs +++ b/xmtp_mls/src/storage/encrypted_store/mod.rs @@ -154,15 +154,22 @@ impl EncryptedMessageStore { if self.enc_key.is_some() { let cipher_version = sql_query("PRAGMA cipher_version").load::(conn)?; + if cipher_version.is_empty() { + return Err(StorageError::SqlCipherNotLoaded); + } let cipher_provider_version = sql_query("PRAGMA cipher_provider_version").load::(conn)?; log::info!( - "Sqlite cipher_version={}, cipher_provider_version={}", - cipher_version[0].cipher_version, - cipher_provider_version[0].cipher_provider_version, + "Sqlite cipher_version={:?}, cipher_provider_version={:?}", + cipher_version.first().as_ref().map(|v| &v.cipher_version), + cipher_provider_version + .first() + .as_ref() + .map(|v| &v.cipher_provider_version) ); if log_enabled!(log::Level::Info) { - conn.batch_execute("PRAGMA cipher_log = stderr; PRAGMA cipher_log_level = INFO;")?; + conn.batch_execute("PRAGMA cipher_log = stderr; PRAGMA cipher_log_level = INFO;") + .ok(); } } diff --git a/xmtp_mls/src/storage/errors.rs b/xmtp_mls/src/storage/errors.rs index 423e0fd8f..6319cc9f1 100644 --- a/xmtp_mls/src/storage/errors.rs +++ b/xmtp_mls/src/storage/errors.rs @@ -35,6 +35,8 @@ pub enum StorageError { Conflict(String), #[error(transparent)] Intent(#[from] IntentError), + #[error("The SQLCipher Sqlite extension is not present, but an encryption key is given")] + SqlCipherNotLoaded, } impl From> for StorageError {