diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 35a0687b9f95ec..700e658417d2aa 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -4678,6 +4678,8 @@ void ECDH::Initialize(Environment* env, Local target) { void ECDH::New(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); + MarkPopErrorOnReturn mark_pop_error_on_return; + // TODO(indutny): Support raw curves? CHECK(args[0]->IsString()); node::Utf8Value curve(env->isolate(), args[0]); diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js index a1e8fb1d7da4ac..68394dd9bcaff9 100644 --- a/test/parallel/test-crypto-dh.js +++ b/test/parallel/test-crypto-dh.js @@ -159,6 +159,11 @@ secret2 = ecdh2.computeSecret(key1, 'binary', 'buffer'); assert.equal(secret1, secret2.toString('base64')); +// Oakley curves do not clean up ERR stack, it was causing unexpected failure +// when accessing other OpenSSL APIs afterwards. +crypto.createECDH('Oakley-EC2N-3'); +crypto.createHash('sha256'); + // Point formats assert.equal(ecdh1.getPublicKey('buffer', 'uncompressed')[0], 4); let firstByte = ecdh1.getPublicKey('buffer', 'compressed')[0];