class SSHSigSignatureVendor(SignatureVerifier):
Constructors: SSHSigSignatureVendor.from_config(config, keyids), SSHSigSignatureVendor(allowed_signers_file, revocation_file, default_key_command, keyids)
Signature verifier that uses the sshsig Python package for SSH signature verification.
Note: This vendor only supports verification, not signing. The sshsig package does not provide signing functionality. For signing, use SSHCliSignatureVendor.
Supports git config options: - gpg.ssh.allowedSignersFile: File containing allowed SSH public keys - gpg.ssh.revocationFile: File containing revoked SSH public keys - gpg.ssh.defaultKeyCommand: Command to get default SSH key (currently unused)
For SSH signatures, keyids are interpreted as principals (identities) like "[email protected]", consistent with Git's SSH signature model. When keyids are provided, the allowed_signers_file must also be configured, and only signatures from keys associated with those principals will be trusted.
Security features: - Key lifetime validation: Checks valid-after and valid-before options in allowed_signers - Revocation checking: Verifies keys against revocation file if configured
| Class Method | available |
Check if the sshsig Python package is available. |
| Class Method | from |
Create an SSH signature verifier from git configuration. |
| Method | __init__ |
Initialize the SSH signature verifier. |
| Method | verify |
Verify an SSH signature using the sshsig package. |
| Instance Variable | allowed |
Undocumented |
| Instance Variable | default |
Undocumented |
| Instance Variable | revocation |
Undocumented |
| Method | _check |
Check if a key is within its valid lifetime. |
| Method | _check |
Check if a key has been revoked. |
| Method | _load |
Load and parse an allowed_signers file. |
| Method | _load |
Load revoked SSH public keys from a revocation file. |
| Method | _parse |
Parse SSH timestamp format to Unix timestamp. |
| Method | _principal |
Check if a signer's principals match any of the allowed principals. |
| Method | _signers |
Convert AllowedSigner objects to PublicKey objects. |
Inherited from SignatureVerifier:
| Instance Variable | keyids |
Undocumented |
Check if the sshsig Python package is available.
| Returns | |
bool | True if sshsig package can be imported, False otherwise |
Config | None = None, keyids: Iterable[ str] | None = None) -> SSHSigSignatureVendor:
¶
Create an SSH signature verifier from git configuration.
| Parameters | |
config:Config | None | Git configuration to read settings from |
keyids:Iterable[ | Optional iterable of trusted SSH key fingerprints for verification |
| Returns | |
SSHSigSignatureVendor | SSHSigSignatureVendor instance configured from the config |
str | None = None, revocation_file: str | None = None, default_key_command: str | None = None, keyids: Iterable[ str] | None = None):
¶
Initialize the SSH signature verifier.
| Parameters | |
allowedstr | None | Path to allowed signers file |
revocationstr | None | Path to file containing revoked SSH public keys |
defaultstr | None | Command to get default SSH key (currently unused) |
keyids:Iterable[ | Optional iterable of trusted principals (identities) like "[email protected]". If provided, requires allowed_signers_file to be configured. Only signatures from keys associated with these principals will be trusted. This matches Git's -I flag in ssh-keygen -Y verify. |
Verify an SSH signature using the sshsig package.
Note
For SSH signatures, keyids are interpreted as principals (identities) like "[email protected]", consistent with Git's SSH signature model. When keyids are provided, only signatures from keys associated with those principals (or wildcard "*" principals) will be trusted.
| Parameters | |
data:bytes | The data that was signed |
signature:bytes | The SSH signature to verify (armored format) |
| Raises | |
UntrustedSignature | if no allowed signers are configured or if signature is not from a trusted principal |
BadSignature | if signature verification fails |
Check if a key is within its valid lifetime.
| Parameters | |
signer:sshsig.allowed_signers.AllowedSigner | AllowedSigner object with optional lifetime constraints |
currentint | Current Unix timestamp to check against |
| Raises | |
UntrustedSignature | if key is not yet valid or has expired |
sshsig.ssh_public_key.PublicKey, revoked_keys: list[ sshsig.ssh_public_key.PublicKey]):
¶
Check if a key has been revoked.
| Parameters | |
key:sshsig.ssh_public_key.PublicKey | PublicKey to check |
revokedlist[ | List of revoked PublicKey objects |
| Raises | |
UntrustedSignature | if the key has been revoked |
Load and parse an allowed_signers file.
| Parameters | |
path:str | Path to the allowed_signers file |
| Returns | |
list[ | List of AllowedSigner objects |
| Raises | |
UntrustedSignature | if file not found or invalid format |
Load revoked SSH public keys from a revocation file.
The revocation file format is the same as authorized_keys: each line contains a public key in OpenSSH format.
| Parameters | |
path:str | Path to the revocation file |
| Returns | |
list[ | List of revoked PublicKey objects |
| Raises | |
UntrustedSignature | if file cannot be read or contains invalid keys |
Parse SSH timestamp format to Unix timestamp.
Supports Git's SSH timestamp formats: - YYYYMMDD[Z] - YYYYMMDDHHMM[SS][Z]
| Parameters | |
timestampstr | Timestamp string to parse |
| Returns | |
int | Unix timestamp (seconds since epoch) |
| Raises | |
UntrustedSignature | if timestamp format is invalid |
Check if a signer's principals match any of the allowed principals.
| Parameters | |
signerstr | Comma-separated principals from allowed_signers file (e.g., "[email protected],[email protected]" or "*") |
allowedlist[ | List of principals to match against |
| Returns | |
bool | True if any signer principal matches any allowed principal, or if signer_principals is "*" (wildcard) |
list[ sshsig.allowed_signers.AllowedSigner]) -> list[ sshsig.ssh_public_key.PublicKey]:
¶
Convert AllowedSigner objects to PublicKey objects.
| Parameters | |
signers:list[ | List of AllowedSigner objects |
| Returns | |
list[ | List of PublicKey objects |
| Raises | |
UntrustedSignature | if any key cannot be parsed |