Open with encryption key loaded from a file.
(
path: &Path,
use_direct_io: bool,
key_path: &Path,
)
| 9 | impl WalManager { |
| 10 | /// Open with encryption key loaded from a file. |
| 11 | pub fn open_encrypted( |
| 12 | path: &Path, |
| 13 | use_direct_io: bool, |
| 14 | key_path: &Path, |
| 15 | ) -> crate::Result<Self> { |
| 16 | let key = |
| 17 | nodedb_wal::crypto::WalEncryptionKey::from_file(key_path).map_err(crate::Error::Wal)?; |
| 18 | let ring = nodedb_wal::crypto::KeyRing::new(key); |
| 19 | let mut mgr = Self::open(path, use_direct_io)?; |
| 20 | { |
| 21 | let mut wal = mgr.wal.lock().unwrap_or_else(|p| p.into_inner()); |
| 22 | wal.set_encryption_ring(ring.clone()) |
| 23 | .map_err(crate::Error::Wal)?; |
| 24 | } |
| 25 | mgr.encryption_ring = Some(ring); |
| 26 | info!(key_path = %key_path.display(), "WAL encryption enabled"); |
| 27 | Ok(mgr) |
| 28 | } |
| 29 | |
| 30 | /// Open with key rotation: current key + previous key for dual-key reads. |
| 31 | /// |
nothing calls this directly
no test coverage detected