Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting active_root_key parallel to loading key #8788

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/server/system_services/master_key_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MasterKeysManager {
decipher = crypto.createDecipheriv(m_key.cipher_type, m_key.cipher_key, m_key.cipher_iv);
}
return new SensitiveString(decipher.update(
Buffer.from(params.encrypted_value, 'base64')).toString());
Buffer.from(params.encrypted_value, 'base64')).toString());
}
});
}
Expand Down Expand Up @@ -86,6 +86,9 @@ class MasterKeysManager {
this.last_load_time = new Date();
const root_keys = await fs.promises.readdir(config.ROOT_KEY_MOUNT);
const active_root_key_id = await fs.promises.readFile(active_root_key_path, 'utf8');
this.active_root_key = active_root_key_id;
dbg.log0(`load_root_keys_from_mount: Root keys was updated at: ${this.last_load_time}. ` +
`active root key is: ${this.active_root_key}`);
for (const key_id of root_keys) {
// skipping file named active_root_key - as we already handled it
// also skipping some garbage files k8s adding to the mount
Expand All @@ -95,9 +98,6 @@ class MasterKeysManager {
const r_key = this._add_to_resolved_keys(key_id, key_cipher, key_id !== active_root_key_id);
this.root_keys_by_id[key_id] = r_key;
}
this.active_root_key = active_root_key_id;
dbg.log0(`load_root_keys_from_mount: Root keys was updated at: ${this.last_load_time}. ` +
`active root key is: ${this.active_root_key}`);
this.is_initialized = true;
}

Expand Down Expand Up @@ -298,7 +298,7 @@ class MasterKeysManager {
if (!_id) throw new Error(`set_m_key_disabled_val: master key id ${_id} was not found`);
const m_key = this.get_master_key_by_id(_id);
if (!m_key) throw new Error('NO_SUCH_KEY');
this.resolved_master_keys_by_id[_id.toString()] = {...m_key, disabled: val };
this.resolved_master_keys_by_id[_id.toString()] = { ...m_key, disabled: val };
}

remove_secret_key_pair_from_cache(old_encrypted_sec_key) {
Expand Down