mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
crypto: clear OpenSSL error queue after calling X509_verify()
Prior to this commit, functions accessing the OpenSSL error queue did not work properly after x509.verify() returned false. PR-URL: https://github.com/nodejs/node/pull/45377 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
1 parent
bbba42fcb2
commit
efe19eb7f5
2 files changed
+7
No files matched your search
@@ -468,6 +468,8 @@ void X509Certificate::Verify(const FunctionCallbackInfo<Value>& args) {
|
||||
ASSIGN_OR_RETURN_UNWRAP(&key, args[0]);
|
||||
CHECK_EQ(key->Data()->GetKeyType(), kKeyTypePublic);
|
||||
|
||||
ClearErrorOnReturn clear_error_on_return;
|
||||
|
||||
args.GetReturnValue().Set(
|
||||
X509_verify(
|
||||
cert->get(),
|
||||
|
||||
@@ -186,6 +186,11 @@ const der = Buffer.from(
|
||||
code: 'ERR_INVALID_ARG_VALUE'
|
||||
});
|
||||
|
||||
// Confirm failure of X509Certificate:verify() doesn't affect other functions that use OpenSSL.
|
||||
assert(!x509.verify(x509.publicKey));
|
||||
// This call should not throw.
|
||||
createPrivateKey(key);
|
||||
|
||||
// X509Certificate can be cloned via MessageChannel/MessagePort
|
||||
const mc = new MessageChannel();
|
||||
mc.port1.onmessage = common.mustCall(({ data }) => {
|
||||
|
||||
Reference in new issue
Block a user