pub struct HostKeyStore { /* private fields */ }Expand description
Persistent store of trusted SSH host keys (analogous to ~/.ssh/known_hosts).
Internally lazily loaded on first use. Safe to clone Arc<HostKeyStore>
across many connections — all access is serialised through an async Mutex.
Implementations§
Source§impl HostKeyStore
impl HostKeyStore
pub fn new(path: PathBuf) -> Self
Sourcepub fn default_path() -> PathBuf
pub fn default_path() -> PathBuf
Default location: $XDG_CONFIG_HOME/r-shell/known_hosts (or platform
equivalent via dirs::config_dir()).
pub fn path(&self) -> &Path
Sourcepub async fn verify(
&self,
host: &str,
port: u16,
key: &PublicKey,
) -> Result<Verdict>
pub async fn verify( &self, host: &str, port: u16, key: &PublicKey, ) -> Result<Verdict>
Check whether the server-offered key matches the stored fingerprint for
(host, port). Does not mutate the store.
Sourcepub async fn trust(&self, host: &str, port: u16, key: &PublicKey) -> Result<()>
pub async fn trust(&self, host: &str, port: u16, key: &PublicKey) -> Result<()>
Persist the server-offered key as trusted for (host, port).
Creates the parent directory if missing.
Sourcepub async fn forget(&self, host: &str, port: u16) -> Result<bool>
pub async fn forget(&self, host: &str, port: u16) -> Result<bool>
Forget a previously-trusted host. Returns true if an entry was
removed, false if there was nothing to remove. Used by the UI’s
“Trust new key” flow on a HostKeyMismatch: forget the stale
entry, retry the connect, the next verify() falls through to
Verdict::Unknown and the new key is TOFU-trusted.