test: update OpenSSL 3.0.0-alpha15 error messages

PR-URL: https://github.com/nodejs/node/pull/38451
Fixes: https://github.com/nodejs/node/issues/38373
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Daniel Bevenius 2021-04-28 12:49:26 +02:00 committed by Richard Lau
parent aed17e963a
commit 67ea715209
No known key found for this signature in database
GPG Key ID: C43CEC45C17AB93C
7 changed files with 26 additions and 18 deletions

View File

@ -226,7 +226,7 @@ assert.throws(() => {
crypto.generateKeyPairSync('ec', { namedCurve: not256k1 }));
}, common.hasOpenSSL3 ? {
name: 'Error',
code: 'ERR_OSSL_EC_INCOMPATIBLE_OBJECTS'
code: 'ERR_OSSL_MISMATCHING_SHARED_PARAMETERS'
} : {
name: 'Error',
code: 'ERR_OSSL_EVP_DIFFERENT_PARAMETERS'

View File

@ -328,7 +328,10 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
type: 'pkcs1'
});
createPrivateKey({ key, format: 'der', type: 'pkcs1' });
}, {
}, common.hasOpenSSL3 ? {
message: /error:1E08010C:DECODER routines::unsupported/,
library: 'DECODER routines'
} : {
message: /asn1 encoding/,
library: 'asn1 encoding routines'
});
@ -514,7 +517,8 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
// Reading an encrypted key without a passphrase should fail.
assert.throws(() => createPrivateKey(privateDsa), common.hasOpenSSL3 ? {
name: 'Error',
message: 'Failed to read private key',
message: 'error:07880109:common libcrypto routines::interrupted or ' +
'cancelled',
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
@ -540,7 +544,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
passphrase: Buffer.alloc(1024, 'a')
}), {
message: common.hasOpenSSL3 ?
'Failed to read private key' :
'error:07880109:common libcrypto routines::interrupted or cancelled' :
/bad decrypt/
});

View File

@ -213,7 +213,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
const publicKey = { key: publicKeyDER, ...publicKeyEncoding };
const expectedError = common.hasOpenSSL3 ? {
name: 'Error',
message: 'Failed to read private key'
message: 'error:07880109:common libcrypto routines::interrupted or ' +
'cancelled'
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
@ -477,7 +478,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => testSignVerify(publicKey, privateKey),
common.hasOpenSSL3 ? {
message: 'Failed to read private key'
message: 'error:07880109:common libcrypto ' +
'routines::interrupted or cancelled'
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
@ -510,7 +512,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => testSignVerify(publicKey, privateKey),
common.hasOpenSSL3 ? {
message: 'Failed to read private key'
message: 'error:07880109:common libcrypto ' +
'routines::interrupted or cancelled'
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
@ -546,7 +549,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => testSignVerify(publicKey, privateKey),
common.hasOpenSSL3 ? {
message: 'Failed to read private key'
message: 'error:07880109:common libcrypto ' +
'routines::interrupted or cancelled'
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',
@ -583,7 +587,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => testSignVerify(publicKey, privateKey),
common.hasOpenSSL3 ? {
message: 'Failed to read private key'
message: 'error:07880109:common libcrypto ' +
'routines::interrupted or cancelled'
} : {
name: 'TypeError',
code: 'ERR_MISSING_PASSPHRASE',

View File

@ -35,6 +35,7 @@ function decrypt(key) {
decrypt(pkey);
assert.throws(() => decrypt(pkeyEncrypted), common.hasOpenSSL3 ?
{ message: 'Failed to read asymmetric key' } :
{ message: 'error:07880109:common libcrypto routines::interrupted or ' +
'cancelled' } :
{ code: 'ERR_MISSING_PASSPHRASE' });
decrypt(pkey); // Should not throw.

View File

@ -37,10 +37,11 @@ const openssl1DecryptError = {
};
const decryptError = common.hasOpenSSL3 ?
{ message: 'Failed to read asymmetric key' } : openssl1DecryptError;
{ message: 'error:1C800064:Provider routines::bad decrypt' } :
openssl1DecryptError;
const decryptPrivateKeyError = common.hasOpenSSL3 ? {
message: 'Failed to read private key',
message: 'error:1C800064:Provider routines::bad decrypt',
} : openssl1DecryptError;
function getBufferCopy(buf) {

View File

@ -44,9 +44,7 @@ const keySize = 2048;
`-----BEGIN RSA PRIVATE KEY-----
AAAAAAAAAAAA
-----END RSA PRIVATE KEY-----`);
}, { message: common.hasOpenSSL3 ?
'Failed to read private key' :
'bye, bye, library' });
}, { message: 'bye, bye, library' });
delete Object.prototype.library;

View File

@ -224,7 +224,7 @@ server.listen(0, common.mustCall(function() {
})).unref();
const errMessagePassword = common.hasOpenSSL3 ?
/Error: PEM_read_bio_PrivateKey/ : /bad decrypt/;
/Error: error:1400006B:UI routines::processing error/ : /bad decrypt/;
// Missing passphrase
assert.throws(function() {
@ -254,8 +254,7 @@ assert.throws(function() {
});
}, errMessagePassword);
const errMessageDecrypt = common.hasOpenSSL3 ?
/Error: PEM_read_bio_PrivateKey/ : /bad decrypt/;
const errMessageDecrypt = /bad decrypt/;
// Invalid passphrase
assert.throws(function() {