-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Addon is broken if building from source using an OpenSSL version different than the one used by Node.js #164
Comments
New findings added to the SO question I've asked some time ago: https://stackoverflow.com/questions/52672253/how-to-compile-node-js-native-addon-against-own-openssl-library I will probably work on what I mentioned above. Using a different OpenSSL version for each Node.js version. This will be done only on Unix tho, doing that for Windows would be too costly right now. Besides that I got the build to work on Windows using Node.js 10 by upgrading the OpenSSL version to 1.1.0. |
Hey. I have no problems on Windows...
var addon = require('./cryptowrap');
exports.CreateDigest = (algorithm, data) => { return addon.CreateDigest(algorithm, data) };
var crypt = require('./callFunc.js');
console.log(crypt .CreateDigest('bash256', Buffer.from(''))); Work fine nodejs 11.13.0, 10.15.3, 10.4.0, 8.15.0 But only on Windows... On Linux algorithm not found. NodeJS use own openssl and I can't win yet...... What can i do? Compile openssl with --shared_openssl? |
@Not4me can you post that as an issue on https://github.com/nodejs/help? Since it's not related to this module in particular, if you want you can also post on the issue I created there, it's on the original issue above |
This is fixed on A bump to |
@JCMais Great Work. I have encountered similar problems. Can you explain your solution in detail? Is there any PR to solve this problem? How can I solve the problem of duplication between the symbols in the node and the symbols in the library I introduced? |
The solution is more of a workaround, basically, you need to make sure you are always building the same version of OpenSSL than the one used by Node.js. You will introduce duplicated symbols, but they will not cause segmentation faults, as they are the same. |
This can solve the problem, Thanks. but some third-party librarys that node depend on are very common. I think the best solution is to introduce these libraries into node in the form of dynamic libraries. |
It causes a segmentation fault, that is, when it does build.
This has been going on for some time, it's probably the cause of many issues: #130 #136 #137 #147 #160
Starting with Node.js 10 OpenSSL symbols were included on the Node.js lib, and the OpenSSL bundled with Node.js was bumped to
1.1.0
.I'm pretty sure this is the root cause of the current problems. Looks like the addon sometimes uses those instead of the ones from the OpenSSL it's compiled with. And since the version differs (the current version of the addon on npm,
1.3.3
, is using1.0.2o
), it causes a segmentation fault.One way to fix that was by upgrading OpenSSL so the versions match, however by doing so the build started to fail on pretty much all Node.js versions.
node-gyp
adds the OpenSSL headers folder used by Node.js as search folders during compilation, and they take precedence over the ones supplied by our own OpenSSL.Besides that, Node.js didn't exported all OpenSSL symbols, just a subset of them, I've made this PR to try to allow the export of the ones required by libssh and libcurl: nodejs/node#23344
I've opened the following issue to try to track down how to correctly solve that since, currently, I do not have that much expertise with linking problems:
nodejs/node-gyp#1559
nodejs/help#1724
While no correct solution is pointed out, looks like I found a workaround: renaming the OpenSSL include folder that node-gyp adds to the list of search paths for header files, that way the ones inside the addon own OpenSSL takes precedence.
The text was updated successfully, but these errors were encountered: