The cause of the matter is this. For some reason, I have been writing Nodejs' c++ module recently and then called it on js. Network communication is naturally inseparable from ssl, so it is necessary to link to Openssl's library.
Our original expectation was that the user needs to install the Openssl runtime library, and then our c++ module dynamically links to the Openssl so library to run.
Everything looked pretty good at first until we found out that this openssl function doesn't work:
PKCS7_sign()
PKCS7_sign ( )
We found:
If our c++ module is dynamically linked to the Openssl library, there is no problem in compiling. However, if the operation occurs, an error that cannot be found in the PKCS7_sign symbol.
If our c++ module is statically linked to the Openssl library, there is no problem with compilation, but when running, the call to this function has no effect, and the return value of this function is 0. According to the document, an error occurred, but using Openssl's function ERR_get_error to obtain the error code is also 0. It means there is no error code.
This is true on Linux, what about on Mac? I tried it with Mac and found that there was no problem with Mac. So I thought that this might be a bug in Nodejs. Then I went to Nodejs and reported it a bug: [https://github.com/joyent/node/issues/8026][1]
At the same time, I searched for keywords similar to nodejs linking to openssl on Google.
Found a few articles like this:
https://github.com/TooTallNate/node-gyp/wiki/Linking-to-OpenSSL
https://github.com/joyent/node/issues/3915
http://serverfault.com/questions/338092/how-can-i-build-node-js-using-static-libssl-and-crypto-libraries
https://github.com/robhawkes/node-extension/issues/1
Through searching, we found that Nodejs itself also used the Openssl library. It is speculated that nodejs's own crypto module is also implemented using Openssl lib. This can be found from the source code of Nodejs, which contains all the latest Openssl source code.
The handsome guy who wrote the first article above: https://github.com/TooTallNate/node-gyp/wiki/Linking-to-OpenSSL is the developer of Nodejs.
Basic conclusion:
Nodejs uses Openssl itself
Before Nodejs 0.6, Nodejs was dynamically linked to the Openssl library. The subsequent versions were statically linked.
At this time, I found that Node had replied to my bug: https://github.com/joyent/node/issues/8026
Node explains why:
After Node compiles itself, it clears the symbols that it does not use, so we can't find the symbols when running. So they fixed the bug and retained all the symbols. This caused the Node to be 400k larger.
Thanks to Node for his quick reply, I have to admire Node's activity level. Like.