Different approaches to access OpenSSL from Node.js

Now I'm looking for a way to integrate OpenSSL and Node.js.

My goals:

  • I want to be platform independent, so the solution should work on OS X, Linux, and Windows.
  • I want to avoid unnecessary disk operations. For example, the private key may not be in the file, but in the database (maybe this is a stupid example, but consider this a valid requirement).
  • I want to support the creation of keys, csrs, sign csrs, create ca certificates, ... all certificate materials, from end to end.

Now the options that I have reviewed are as follows:

  • Use the OpenSSL library, which is integrated into Node.js. Unfortunately, the crypto module does not provide certificate information.
  • Use the OpenSSL library with an external module. Unfortunately, I don't know how to do this, possibly due to a lack of knowledge in C / C ++.
  • Use the OpenSSL binary as a child process. Given that OpenSSL is available, this should work on all platforms. This is not nice, but it works.

Question No. 1: As I already wrote, I have no idea how to directly access the OpenSSL library, which comes bundled with Node.js. How do I approach this?

I am currently using the binary as a child process. Unfortunately, this requires that all such things as private keys, etc., are either specified as files (which I clearly want to avoid), or I transfer everything using / dev / stdin (which does not work on Windows).

Question # 2: How can I handle this? Will solution # 1 solve this problem too?

+6
source share
1 answer

The answer to question No. 1 is that you cannot. Without bindings, you can only access functions opened by nodejs.

Unfortunately for windows / dev / stdin there is no way to work in windows. Namedpipes will be an option, but nodejs does not support them. You can have nodejs run openssl.exe interactively and send commands via stdin and read the output via stdout, but this seems very inefficient.

So, the answer to question No. 2 is that you cannot deal with the Windows problem.

Writing your winnings is apparently the only option. This is actually not that difficult - I'm sure you could help the staff.

+2
source

All Articles