GeezerVison is showing github.com — crypto: clear OpenSSL error queue after calling X509_verify() · nodejs/node@dae92e7
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/crypto/crypto_x509.cc +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -468,6 +468,8 @@ void X509Certificate::Verify(const FunctionCallbackInfo<Value>& args) { |
468 | 468 | ASSIGN_OR_RETURN_UNWRAP(&key, args[0]); |
469 | 469 | CHECK_EQ(key->Data()->GetKeyType(), kKeyTypePublic); |
470 | 470 |
|
| 471 | + ClearErrorOnReturn clear_error_on_return; |
| 472 | + |
471 | 473 | args.GetReturnValue().Set( |
472 | 474 | X509_verify( |
473 | 475 | cert->get(), |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-crypto-x509.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -186,6 +186,11 @@ const der = Buffer.from( |
186 | 186 | code: 'ERR_INVALID_ARG_VALUE' |
187 | 187 | }); |
188 | 188 |
|
| 189 | + // Confirm failure of X509Certificate:verify() doesn't affect other functions that use OpenSSL. |
| 190 | + assert(!x509.verify(x509.publicKey)); |
| 191 | + // This call should not throw. |
| 192 | + createPrivateKey(key); |
| 193 | + |
189 | 194 | // X509Certificate can be cloned via MessageChannel/MessagePort |
190 | 195 | const mc = new MessageChannel(); |
191 | 196 | mc.port1.onmessage = common.mustCall(({ data }) => { |
|