You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ssh2_pem_parse_memory() skips the first line of an unencrypted OpenSSL key #2130
changed the title [-]ssh2_pem_parse_memory() does not reat private RSA keys[/-][+]ssh2_pem_parse_memory() does not read private RSA keys[/+]on Jun 28, 2026
reads the next line of the key (first line of the actual key)
As I have no passphrase the next code if(passphrase && ...
is skipped, and then *line = '\0';
clears the first line of the key.
changed the title [-]ssh2_pem_parse_memory() does not read private RSA keys[/-][+]ssh2_pem_parse_memory() skips the first line of an unencrypted OpenSSL key[/+]on Jun 29, 2026
Activity
[-]ssh2_pem_parse_memory() does not reat private RSA keys[/-][+]ssh2_pem_parse_memory() does not read private RSA keys[/+]willco007 commentedon Jun 29, 2026
Can you attach a sample key that fails? Thanks.
R6502 commentedon Jun 29, 2026
Don't wanna post my private RSA key, but it's in the format
And the problem should be easily to see:
When the loop
ends,
linecontains "-----BEGIN RSA PRIVATE KEY-----"Then
reads the next line of the key (first line of the actual key)
As I have no passphrase the next code
if(passphrase && ...is skipped, and then
*line = '\0';clears the first line of the key.
willco007 commentedon Jun 29, 2026
Looks like it was broken with this MR #1746
willco007 commentedon Jun 29, 2026
If you remove
*line = '\0';does it fix it for you? That seems to be the only change required as far as I can tell.[-]ssh2_pem_parse_memory() does not read private RSA keys[/-][+]ssh2_pem_parse_memory() skips the first line of an unencrypted OpenSSL key[/+]R6502 commentedon Jun 29, 2026
Yes, I removed it here and it's working now.
However, I never use the
passphraseso I tested only without it.willco007 commentedon Jun 29, 2026
Thanks for the conformation. I was just diff'ing the #1746 commit and it seems to have spuriously been added. I will create an MR removing it.
pem.c: Fix incorrect line clearing (libssh2#2137)