|
| 1 | +import os |
1 | 2 | from base64 import b64decode, b64encode |
2 | 3 | from collections.abc import Sequence |
3 | 4 | from dataclasses import dataclass |
@@ -69,9 +70,13 @@ class SecretStore(PostgresTable): |
69 | 70 | @classmethod |
70 | 71 | def _list_ssh_keys(cls) -> list[AgentKey]: |
71 | 72 | """List all SSH keys available in the ssh-agent.""" |
72 | | - keys = list(SSHAgent().get_keys()) |
| 73 | + try: |
| 74 | + keys = list(SSHAgent().get_keys()) |
| 75 | + except (SSHException, ConnectionError) as e: |
| 76 | + logger.warning(f"Failed to communicate with ssh-agent: {e}") |
| 77 | + keys = [] |
73 | 78 |
|
74 | | - if not keys: |
| 79 | + if not keys and not os.environ.get("ODEV_NO_SSH_AGENT"): |
75 | 80 | raise OdevError("No SSH keys found in ssh-agent, or ssh-agent is not running.") |
76 | 81 |
|
77 | 82 | fingerprint = cls.config.security.encryption_key |
@@ -266,7 +271,13 @@ def _get( |
266 | 271 | return None |
267 | 272 |
|
268 | 273 | logger.debug(f"Secret '{name}:{scope}:{platform}' retrieved from storage") |
269 | | - return Secret(name, result[0][0], SecretStore.decrypt(result[0][1]), scope, platform) |
| 274 | + try: |
| 275 | + password = SecretStore.decrypt(result[0][1]) |
| 276 | + except OdevError: |
| 277 | + logger.debug(f"Failed to decrypt secret '{name}:{scope}:{platform}', treating as missing") |
| 278 | + return None |
| 279 | + |
| 280 | + return Secret(name, result[0][0], password, scope, platform) |
270 | 281 |
|
271 | 282 | def _set(self, secret: Secret): |
272 | 283 | """Save a secret to the vault. |
|
0 commit comments