node icon indicating copy to clipboard operation
node copied to clipboard

crypto.generateKeyPair* support in electron node

Open Kaimaerah opened this issue 7 years ago • 4 comments

I recently updated my project to the latest electron beta (5.0.0-beta.1) which uses node "12" (electron-node-canary) as I was hoping to make use of crypto.generateKeyPairSync that was introduced in node v10.12. Unfortunately, when I call the function, I get the following error TypeError: crypto.generateKeyPairSync is not a function, despite the fact that it works on node latest and lts/dubnium

I've noticed that in the canary branch that feature had been reverted (see commit: https://github.com/electron/node/commit/c9f4c6fa24cc12dccf53fb29ea503d3b8a95a983). What was the reason for removing this feature from the latest node build, and is there a chance of bringing it back in?

Kaimaerah avatar Jan 31 '19 00:01 Kaimaerah

@Kaimaerah That particular API depends on APIs inside OpenSSL that do not exist inside BoringSSL. It would be possible to rewrite that API to use BoringSSL APIs but it is a not-trivial amount of work.

MarshallOfSound avatar Jan 31 '19 00:01 MarshallOfSound

@MarshallOfSound @codebytere do you want me to look into this?

ryzokuken avatar Jan 31 '19 06:01 ryzokuken

I would like to see this too please :) if I run Node on its own I can use generateKeyPair but not within electron. Is there a way to call the Node crypto module from Electron?

aykay76 avatar Feb 09 '19 09:02 aykay76

@ryzokuken that would be 💯

@aykay76 we bundle the entirety of Node.js in Electron, you can run the module it's just that we tweak it to build with BoringSSL instead of OpenSSL for compatibility with Chromium. So the path forward here is to modify our fork to allow it to accomplish what you seek.

codebytere avatar Feb 09 '19 17:02 codebytere