wasat.trust
Trust models and certificate verification for Gemini connections.
FileTrustStore
Bases: TrustStore
A standard file-based TOFU (Trust On First Use) store.
Stores fingerprints in a simple text file format similar to known_hosts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Path
|
The path to the file storing fingerprints. |
required |
filepath
instance-attribute
The path to the file storing the certificate fingerprints.
get_fingerprint
async
get_hosts
async
save
async
Save the peer certificate fingerprint to the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The remote hostname. |
required |
|
int
|
The remote port. |
required |
|
bytes
|
The DER-encoded certificate. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If saving the updated known hosts file to disk fails. |
verify
async
Verify the peer certificate against the stored fingerprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The remote hostname. |
required |
|
int
|
The remote port. |
required |
|
bytes
|
The DER-encoded certificate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the fingerprint matches the stored one, False otherwise. |
TrustStore
Bases: Protocol
Protocol defining the interface for certificate fingerprint stores.
get_fingerprint
async
get_hosts
async
save
async
Save a peer certificate fingerprint to the trust store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The remote hostname. |
required |
|
int
|
The remote port. |
required |
|
bytes
|
The DER-encoded certificate. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If saving the certificate fingerprint to the trust store fails. |
verify
async
Verify the peer certificate against the stored fingerprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The remote hostname. |
required |
|
int
|
The remote port. |
required |
|
bytes
|
The DER-encoded certificate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the certificate is trusted, False otherwise. |