Open Timmmm opened 4 years ago
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 ssh2
, this isn't a problem anymore (ssh2-streams
is no longer used).
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.)