mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-03 00:14:21 +01:00
Merge 'Prevent setting of encryption keys if already set' from Gaurav Sarma
Fixes https://github.com/tursodatabase/turso/issues/2883 <img width="867" height="128" alt="Screenshot 2025-09-05 at 10 44 18 PM" src="https://github.com/user-attachments/assets/54a659ba- cfe1-4622-939b-c7c31362ee5a" /> Reviewed-by: Pere Diaz Bou <pere-altea@homail.com> Reviewed-by: Avinash Sajjanshetty (@avinassh) Closes #2914
This commit is contained in:
@@ -2060,6 +2060,11 @@ impl Connection {
|
||||
};
|
||||
tracing::trace!("setting encryption ctx for connection");
|
||||
let pager = self.pager.borrow();
|
||||
if pager.is_encryption_ctx_set() {
|
||||
return Err(LimboError::InvalidArgument(
|
||||
"cannot reset encryption attributes if already set in the session".to_string(),
|
||||
));
|
||||
}
|
||||
pager.set_encryption_context(cipher_mode, key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2163,6 +2163,10 @@ impl Pager {
|
||||
Ok(IOResult::Done(f(header)))
|
||||
}
|
||||
|
||||
pub fn is_encryption_ctx_set(&self) -> bool {
|
||||
self.io_ctx.borrow_mut().encryption_context().is_some()
|
||||
}
|
||||
|
||||
pub fn set_encryption_context(
|
||||
&self,
|
||||
cipher_mode: CipherMode,
|
||||
|
||||
Reference in New Issue
Block a user