GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: clear OpenSSL error queue after calling X509_check_private_key() · nodejs/node@f27ebab

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/crypto
    • crypto_x509.cc
  • test/parallel
    • test-crypto-x509.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/crypto/crypto_x509.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_x509.cc
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,8 @@ void X509Certificate::CheckPrivateKey(const FunctionCallbackInfo<Value>& args) {
453453
ASSIGN_OR_RETURN_UNWRAP(&key, args[0]);
454454
CHECK_EQ(key->Data()->GetKeyType(), kKeyTypePrivate);
455455

456+
ClearErrorOnReturn clear_error_on_return;
457+
456458
args.GetReturnValue().Set(
457459
X509_check_private_key(
458460
cert->get(),
Collapse file

‎test/parallel/test-crypto-x509.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-x509.js
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if (!common.hasCrypto)
88
const {
99
X509Certificate,
1010
createPrivateKey,
11+
generateKeyPairSync,
1112
} = require('crypto');
1213

1314
const {
@@ -186,10 +187,18 @@ const der = Buffer.from(
186187
code: 'ERR_INVALID_ARG_VALUE'
187188
});
188189

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);
190+
{
191+
// https://github.com/nodejs/node/issues/45377
192+
// https://github.com/nodejs/node/issues/45485
193+
// Confirm failures of X509Certificate:verify() and X509Certificate:CheckPrivateKey()
194+
// do not affect other functions that use OpenSSL.
195+
// Subsequent calls to e.g. createPrivateKey should not throw.
196+
const keyPair = generateKeyPairSync('ed25519');
197+
assert(!x509.verify(keyPair.publicKey));
198+
createPrivateKey(key);
199+
assert(!x509.checkPrivateKey(keyPair.privateKey));
200+
createPrivateKey(key);
201+
}
193202

194203
// X509Certificate can be cloned via MessageChannel/MessagePort
195204
const mc = new MessageChannel();

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.