Commit bd3accc 1 parent 496912d commit bd3accc Copy full SHA for bd3accc
File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -453,6 +453,8 @@ void X509Certificate::CheckPrivateKey(const FunctionCallbackInfo<Value>& args) {
453
453
ASSIGN_OR_RETURN_UNWRAP (&key, args[0 ]);
454
454
CHECK_EQ (key->Data ()->GetKeyType (), kKeyTypePrivate );
455
455
456
+ ClearErrorOnReturn clear_error_on_return;
457
+
456
458
args.GetReturnValue ().Set (
457
459
X509_check_private_key (
458
460
cert->get (),
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ if (!common.hasCrypto)
8
8
const {
9
9
X509Certificate,
10
10
createPrivateKey,
11
+ generateKeyPairSync,
11
12
} = require ( 'crypto' ) ;
12
13
13
14
const {
@@ -186,10 +187,18 @@ const der = Buffer.from(
186
187
code : 'ERR_INVALID_ARG_VALUE'
187
188
} ) ;
188
189
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
+ }
193
202
194
203
// X509Certificate can be cloned via MessageChannel/MessagePort
195
204
const mc = new MessageChannel ( ) ;
You can’t perform that action at this time.
0 commit comments