-
Notifications
You must be signed in to change notification settings - Fork 145
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
OpenSSH private keys not decoded correctly #163
Comments
Timmmm
pushed a commit
to Timmmm/ssh2-streams
that referenced
this issue
Aug 20, 2020
Numbers that start 0x9... did not have '00' prepended. Fixes mscdex#163
This is currently preventing Mongodb Compass from connecting to a GCE instance using the gcloud compute config-ssh keys. I imagine the problem is pretty widespread, since any Electron app that uses an SSH tunnel (like MongoDB Compass) won't work on Mac. |
As long as modules/users are using modern versions of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We have an OpenSSH key that was generated on MacOS.
ssh2-streams
unfortunately decodes it incorrectly:Running the above code gives:
If you use the above key in Node then it appears to work:
However if you do the same thing in Electron's Renderer (i.e. Chromium) then you get this error:
The difference is that Node uses OpenSSL whereas Chromium uses BoringSSL. BoringSSL is more strict about parsing keys, and according to them, this key is encoded incorrectly. We can get a similar error by saving the above
RSA PRIVATE KEY
toid_rsa
and running BoringSSL on the command line:OpenSSL is more lax and outputs some data:
This is the issue according to David Ben in that link above:
Note that I have tested this both with version 0.4.10, and with
master
, both of which include this recent patch that looks like it was an attempt to fix this.In fact, looking at that fix it makes no sense to me:
You add
00
ifhex
starts with8
ora-f
. What about9
? In fact adding|| sigbit === 57
fixes the issue!I suggest using fewer magic numbers in your code to avoid this in future! It's also easy to check for !(0-7) than 8, 9, a-f, A-F (pretty risky to assume lowercase). Try this code:
(Renamed
sigbit
because it isn't a bit - it is a nibble / hex character.)The text was updated successfully, but these errors were encountered: