crypto: pass empty passphrases to OpenSSL properly
This solves two related problems:
-
PrivateKeyEncodingConfig
was unable to distinguish between "no passphrase" and zero-length passphrases, since both may be stored asByteSource(nullptr, 0)
. - OpenSSL uses its default key callback when a cipher was specified, but a
nullptr
for the passphrase. However, this did happen when an empty passphrase was specified, becausemalloc(0)
is allowed to return anullptr
.
I'm not sure why these problems don't affect older versions.
Fixes: https://github.com/nodejs/node/issues/35898
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines