Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix 20 #21

Merged
merged 7 commits into from
Sep 7, 2024
10 changes: 10 additions & 0 deletions bark_core/signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ def verify_signature(self, email: str, signature: bytes, subject: bytes) -> bool
@classmethod
def _load_blob(cls, identifier: str) -> bytes:
try:
# expanduser to catch relative paths like ~/.ssh/key.pub
identifier = os.path.expanduser(identifier)
with open(identifier, "rb") as f:
pubkey = f.read()
return pubkey
Expand Down Expand Up @@ -386,6 +388,14 @@ def get_authorized_pubkeys(
def get_pubkey_from_git() -> Optional[Pubkey]:
identifier = cmd("git", "config", "user.signingKey", check=False)[0]
if identifier:
gpg_format = cmd("git", "config", "gpg.format", check=False)[0]
# check if signingKey is ssh
if gpg_format and gpg_format == "ssh":
email = cmd("git", "config", "user.email", check=False)[0]
identifier = os.path.expanduser(identifier) # expand path if relative
with open(identifier, 'rb') as file: # read public key
pubkey = file.read()
return SshKey(f"{email} ".encode() + pubkey)
return Pubkey.from_identifier(identifier)
return None

Expand Down
Loading