Skip to content

test: leverage process.features.openssl_is_boringssl in test #58421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions test/parallel/test-crypto-x509.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');

Expand Down Expand Up @@ -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);
}
}

{
Expand Down Expand Up @@ -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-----
Expand Down Expand Up @@ -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'));
}
}
14 changes: 11 additions & 3 deletions test/parallel/test-https-agent-additional-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-https-agent-session-eviction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
6 changes: 4 additions & 2 deletions test/parallel/test-webcrypto-derivebits.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
6 changes: 4 additions & 2 deletions test/parallel/test-webcrypto-derivekey.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
9 changes: 6 additions & 3 deletions test/parallel/test-webcrypto-sign-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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