mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
test: leverage process.features.openssl_is_boringssl in test
PR-URL: https://github.com/nodejs/node/pull/58421 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
e9c6004a2d
commit
cf5cbffbbc
|
|
@ -97,8 +97,6 @@ const der = Buffer.from(
|
|||
assert.strictEqual(x509.infoAccess, infoAccessCheck);
|
||||
assert.strictEqual(x509.validFrom, 'Sep 3 21:40:37 2022 GMT');
|
||||
assert.strictEqual(x509.validTo, 'Jun 17 21:40:37 2296 GMT');
|
||||
assert.deepStrictEqual(x509.validFromDate, new Date('2022-09-03T21:40:37Z'));
|
||||
assert.deepStrictEqual(x509.validToDate, new Date('2296-06-17T21:40:37Z'));
|
||||
assert.strictEqual(
|
||||
x509.fingerprint,
|
||||
'8B:89:16:C4:99:87:D2:13:1A:64:94:36:38:A5:32:01:F0:95:3B:53');
|
||||
|
|
@ -118,6 +116,11 @@ const der = Buffer.from(
|
|||
|
||||
assert.deepStrictEqual(x509.raw, der);
|
||||
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
assert.deepStrictEqual(x509.validFromDate, new Date('2022-09-03T21:40:37Z'));
|
||||
assert.deepStrictEqual(x509.validToDate, new Date('2296-06-17T21:40:37Z'));
|
||||
}
|
||||
|
||||
assert(x509.publicKey);
|
||||
assert.strictEqual(x509.publicKey.type, 'public');
|
||||
|
||||
|
|
@ -356,13 +359,15 @@ tAt3hIKFD1bJt6c6WtMH2Su3syosWxmdmGk5ihslB00lvLpfj/wed8i3bkcB1doq
|
|||
UcXd/5qu2GhokrKU2cPttU+XAN2Om6a0
|
||||
-----END CERTIFICATE-----`;
|
||||
|
||||
const cert = new X509Certificate(certPem);
|
||||
assert.throws(() => cert.publicKey, {
|
||||
message: hasOpenSSL3 ? /decode error/ : /wrong tag/,
|
||||
name: 'Error'
|
||||
});
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
const cert = new X509Certificate(certPem);
|
||||
assert.throws(() => cert.publicKey, {
|
||||
message: hasOpenSSL3 ? /decode error/ : /wrong tag/,
|
||||
name: 'Error'
|
||||
});
|
||||
|
||||
assert.strictEqual(cert.checkIssued(cert), false);
|
||||
assert.strictEqual(cert.checkIssued(cert), false);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -401,8 +406,10 @@ UidvpWWipVLZgK+oDks+bKTobcoXGW9oXobiIYqslXPy
|
|||
-----END CERTIFICATE-----`.trim();
|
||||
const c1 = new X509Certificate(certPemUTCTime);
|
||||
|
||||
assert.deepStrictEqual(c1.validFromDate, new Date('1949-12-25T23:59:58Z'));
|
||||
assert.deepStrictEqual(c1.validToDate, new Date('1950-01-01T23:59:58Z'));
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
assert.deepStrictEqual(c1.validFromDate, new Date('1949-12-25T23:59:58Z'));
|
||||
assert.deepStrictEqual(c1.validToDate, new Date('1950-01-01T23:59:58Z'));
|
||||
}
|
||||
|
||||
// The GeneralizedTime format is used for dates in 2050 or later.
|
||||
const certPemGeneralizedTime = `-----BEGIN CERTIFICATE-----
|
||||
|
|
@ -436,6 +443,8 @@ CWwQO8JZjJqFtqtuzy2n+gLCvqePgG/gmSqHOPm2ZbLW
|
|||
-----END CERTIFICATE-----`.trim();
|
||||
const c2 = new X509Certificate(certPemGeneralizedTime);
|
||||
|
||||
assert.deepStrictEqual(c2.validFromDate, new Date('2049-12-26T00:00:01Z'));
|
||||
assert.deepStrictEqual(c2.validToDate, new Date('2050-01-02T00:00:01Z'));
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
assert.deepStrictEqual(c2.validFromDate, new Date('2049-12-26T00:00:01Z'));
|
||||
assert.deepStrictEqual(c2.validToDate, new Date('2050-01-02T00:00:01Z'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,23 +13,31 @@ const options = {
|
|||
cert: fixtures.readKey('agent1-cert.pem'),
|
||||
ca: fixtures.readKey('ca1-cert.pem'),
|
||||
minVersion: 'TLSv1.1',
|
||||
ciphers: 'ALL@SECLEVEL=0'
|
||||
};
|
||||
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
options.ciphers = 'ALL@SECLEVEL=0';
|
||||
}
|
||||
|
||||
const server = https.Server(options, (req, res) => {
|
||||
res.writeHead(200);
|
||||
res.end('hello world\n');
|
||||
});
|
||||
|
||||
function getBaseOptions(port) {
|
||||
return {
|
||||
const baseOptions = {
|
||||
path: '/',
|
||||
port: port,
|
||||
ca: options.ca,
|
||||
rejectUnauthorized: true,
|
||||
servername: 'agent1',
|
||||
ciphers: 'ALL@SECLEVEL=0'
|
||||
};
|
||||
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
baseOptions.ciphers = 'ALL@SECLEVEL=0';
|
||||
}
|
||||
|
||||
return baseOptions;
|
||||
}
|
||||
|
||||
const updatedValues = new Map([
|
||||
|
|
|
|||
|
|
@ -17,9 +17,12 @@ const options = {
|
|||
key: readKey('agent1-key.pem'),
|
||||
cert: readKey('agent1-cert.pem'),
|
||||
secureOptions: SSL_OP_NO_TICKET,
|
||||
ciphers: 'RSA@SECLEVEL=0'
|
||||
};
|
||||
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
options.ciphers = 'RSA@SECLEVEL=0';
|
||||
}
|
||||
|
||||
// Create TLS1.2 server
|
||||
https.createServer(options, function(req, res) {
|
||||
res.writeHead(200, { 'Connection': 'close' });
|
||||
|
|
|
|||
|
|
@ -123,6 +123,8 @@ const { subtle } = globalThis.crypto;
|
|||
assert.deepStrictEqual(secret1, secret2);
|
||||
}
|
||||
|
||||
test('X25519').then(common.mustCall());
|
||||
test('X448').then(common.mustCall());
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
test('X25519').then(common.mustCall());
|
||||
test('X448').then(common.mustCall());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,6 +206,8 @@ const { KeyObject } = require('crypto');
|
|||
assert.deepStrictEqual(raw1, raw2);
|
||||
}
|
||||
|
||||
test('X25519').then(common.mustCall());
|
||||
test('X448').then(common.mustCall());
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
test('X25519').then(common.mustCall());
|
||||
test('X448').then(common.mustCall());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,8 +121,9 @@ const { subtle } = globalThis.crypto;
|
|||
name: 'Ed25519',
|
||||
}, publicKey, signature, ec.encode(data)));
|
||||
}
|
||||
|
||||
test('hello world').then(common.mustCall());
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
test('hello world').then(common.mustCall());
|
||||
}
|
||||
}
|
||||
|
||||
// Test Sign/Verify Ed448
|
||||
|
|
@ -142,5 +143,7 @@ const { subtle } = globalThis.crypto;
|
|||
}, publicKey, signature, ec.encode(data)));
|
||||
}
|
||||
|
||||
test('hello world').then(common.mustCall());
|
||||
if (!process.features.openssl_is_boringssl) {
|
||||
test('hello world').then(common.mustCall());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user