Skip to content

Commit 881dff7

Browse files
committed
[IMP] Stop encrypting secrets if already encrypted
If multiple keys are loaded in the agent, encryption of secrets will go through each of them instead of stopping at the first one that works.
1 parent 26a3da6 commit 881dff7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

odev/common/store/tables/secrets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ def encrypt(cls, plaintext: str) -> str:
8585
for key in cls._list_ssh_keys():
8686
try:
8787
ciphered = str(b64encode(ssh_encrypt(plaintext, ssh_key=key)).decode()) if plaintext else ""
88+
logger.debug(f"Payload encrypted with key {key.name}")
8889
except SSHException as e:
8990
logger.debug(f"Failed to encrypt with key {key.name}: {e}")
91+
else:
92+
break
9093

9194
if ciphered is None:
9295
raise OdevError("Encryption failed, no key could be used for signing.")

0 commit comments

Comments
 (0)