Skip to content

Commit

Permalink
Fix: Fix handling of SSH keys in modify_credential
Browse files Browse the repository at this point in the history
Merge pull request #1818 from timopollmeier/fix-modify_credential-ssh-key
  • Loading branch information
timopollmeier authored May 5, 2022
2 parents 4fbc793 + f4b3a7f commit 7b16d2e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,20 @@ truncate_private_key (const gchar* private_key)
}
}

if (key_start == NULL)
{
key_start = strstr (private_key, "-----BEGIN OPENSSH PRIVATE KEY-----");
if (key_start)
{
key_end = strstr (key_start, "-----END OPENSSH PRIVATE KEY-----");

if (key_end)
key_end += strlen ("-----END OPENSSH PRIVATE KEY-----");
else
return NULL;
}
}

if (key_end && key_end[0] == '\n')
key_end++;

Expand Down
4 changes: 2 additions & 2 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -34465,7 +34465,7 @@ modify_credential (const char *credential_id,
{
if (key_private_to_use || password)
{
if (check_private_key (key_private_truncated
if (check_private_key (key_private_to_use
? key_private_to_use
: credential_iterator_private_key
(&iterator),
Expand All @@ -34481,7 +34481,7 @@ modify_credential (const char *credential_id,

set_credential_private_key
(credential,
key_private_truncated
key_private_to_use
? key_private_to_use
: credential_iterator_private_key (&iterator),
password
Expand Down

0 comments on commit 7b16d2e

Please sign in to comment.