mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
Revert "test: move all test keys/certs under test/fixtures/keys/"
PR-URL: https://github.com/nodejs/node/pull/28083 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com>
This commit is contained in:
1 parent
9dd840dff5
commit
62de36e8d3
126 files changed
+738
-746
No files matched your search
@@ -41,11 +41,11 @@ const DH_NOT_SUITABLE_GENERATOR = crypto.constants.DH_NOT_SUITABLE_GENERATOR;
|
||||
require('internal/crypto/util').setDefaultEncoding('latin1');
|
||||
|
||||
// Test Certificates
|
||||
const certPem = fixtures.readKey('rsa_cert.crt');
|
||||
const certPfx = fixtures.readKey('rsa_cert.pfx');
|
||||
const keyPem = fixtures.readKey('rsa_private.pem');
|
||||
const rsaPubPem = fixtures.readKey('rsa_public.pem', 'ascii');
|
||||
const rsaKeyPem = fixtures.readKey('rsa_private.pem', 'ascii');
|
||||
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
||||
const certPfx = fixtures.readSync('test_cert.pfx');
|
||||
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
|
||||
const rsaPubPem = fixtures.readSync('test_rsa_pubkey.pem', 'ascii');
|
||||
const rsaKeyPem = fixtures.readSync('test_rsa_privkey.pem', 'ascii');
|
||||
|
||||
// PFX tests
|
||||
tls.createSecureContext({ pfx: certPfx, passphrase: 'sample' });
|
||||
@@ -626,11 +626,14 @@ common.expectsError(
|
||||
|
||||
rsaSign.update(rsaPubPem);
|
||||
const rsaSignature = rsaSign.sign(rsaKeyPem, 'hex');
|
||||
const expectedSignature = fixtures.readKey(
|
||||
'rsa_public_sha1_signature_signedby_rsa_private.sha1',
|
||||
'hex'
|
||||
assert.strictEqual(
|
||||
rsaSignature,
|
||||
'5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' +
|
||||
'8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' +
|
||||
'e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f' +
|
||||
'60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f' +
|
||||
'40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6'
|
||||
);
|
||||
assert.strictEqual(rsaSignature, expectedSignature);
|
||||
|
||||
rsaVerify.update(rsaPubPem);
|
||||
assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
|
||||
@@ -640,15 +643,17 @@ common.expectsError(
|
||||
// Test RSA signing and verification
|
||||
//
|
||||
{
|
||||
const privateKey = fixtures.readKey('rsa_private_b.pem');
|
||||
const publicKey = fixtures.readKey('rsa_public_b.pem');
|
||||
const privateKey = fixtures.readSync('test_rsa_privkey_2.pem');
|
||||
const publicKey = fixtures.readSync('test_rsa_pubkey_2.pem');
|
||||
|
||||
const input = 'I AM THE WALRUS';
|
||||
|
||||
const signature = fixtures.readKey(
|
||||
'I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256',
|
||||
'hex'
|
||||
);
|
||||
const signature =
|
||||
'79d59d34f56d0e94aa6a3e306882b52ed4191f07521f25f505a078dc2f89' +
|
||||
'396e0c8ac89e996fde5717f4cb89199d8fec249961fcb07b74cd3d2a4ffa' +
|
||||
'235417b69618e4bcd76b97e29975b7ce862299410e1b522a328e44ac9bb2' +
|
||||
'8195e0268da7eda23d9825ac43c724e86ceeee0d0d4465678652ccaf6501' +
|
||||
'0ddfb299bedeb1ad';
|
||||
|
||||
const sign = crypto.createSign('SHA256');
|
||||
sign.update(input);
|
||||
@@ -667,8 +672,8 @@ common.expectsError(
|
||||
// Test DSA signing and verification
|
||||
//
|
||||
{
|
||||
const privateKey = fixtures.readKey('dsa_private.pem');
|
||||
const publicKey = fixtures.readKey('dsa_public.pem');
|
||||
const privateKey = fixtures.readSync('test_dsa_privkey.pem');
|
||||
const publicKey = fixtures.readSync('test_dsa_pubkey.pem');
|
||||
|
||||
const input = 'I AM THE WALRUS';
|
||||
|
||||
|
||||
@@ -30,10 +30,9 @@ const { Certificate } = crypto;
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
// Test Certificates
|
||||
const spkacValid = fixtures.readKey('rsa_spkac.spkac');
|
||||
const spkacChallenge = 'this-is-a-challenge';
|
||||
const spkacFail = fixtures.readKey('rsa_spkac_invalid.spkac');
|
||||
const spkacPublicPem = fixtures.readKey('rsa_public.pem');
|
||||
const spkacValid = fixtures.readSync('spkac.valid');
|
||||
const spkacFail = fixtures.readSync('spkac.fail');
|
||||
const spkacPem = fixtures.readSync('spkac.pem');
|
||||
|
||||
function checkMethods(certificate) {
|
||||
|
||||
@@ -42,13 +41,13 @@ function checkMethods(certificate) {
|
||||
|
||||
assert.strictEqual(
|
||||
stripLineEndings(certificate.exportPublicKey(spkacValid).toString('utf8')),
|
||||
stripLineEndings(spkacPublicPem.toString('utf8'))
|
||||
stripLineEndings(spkacPem.toString('utf8'))
|
||||
);
|
||||
assert.strictEqual(certificate.exportPublicKey(spkacFail), '');
|
||||
|
||||
assert.strictEqual(
|
||||
certificate.exportChallenge(spkacValid).toString('utf8'),
|
||||
spkacChallenge
|
||||
'fb9ab814-6677-42a4-a60c-f905d1a6924d'
|
||||
);
|
||||
assert.strictEqual(certificate.exportChallenge(spkacFail), '');
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ const {
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const publicPem = fixtures.readKey('rsa_public.pem', 'ascii');
|
||||
const privatePem = fixtures.readKey('rsa_private.pem', 'ascii');
|
||||
const publicPem = fixtures.readSync('test_rsa_pubkey.pem', 'ascii');
|
||||
const privatePem = fixtures.readSync('test_rsa_privkey.pem', 'ascii');
|
||||
|
||||
const publicDsa = fixtures.readKey('dsa_public_1025.pem', 'ascii');
|
||||
const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
|
||||
@@ -203,18 +203,18 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
|
||||
}
|
||||
|
||||
[
|
||||
{ private: fixtures.readKey('ed25519_private.pem', 'ascii'),
|
||||
public: fixtures.readKey('ed25519_public.pem', 'ascii'),
|
||||
{ private: fixtures.readSync('test_ed25519_privkey.pem', 'ascii'),
|
||||
public: fixtures.readSync('test_ed25519_pubkey.pem', 'ascii'),
|
||||
keyType: 'ed25519' },
|
||||
{ private: fixtures.readKey('ed448_private.pem', 'ascii'),
|
||||
public: fixtures.readKey('ed448_public.pem', 'ascii'),
|
||||
{ private: fixtures.readSync('test_ed448_privkey.pem', 'ascii'),
|
||||
public: fixtures.readSync('test_ed448_pubkey.pem', 'ascii'),
|
||||
keyType: 'ed448' },
|
||||
{ private: fixtures.readKey('x25519_private.pem', 'ascii'),
|
||||
public: fixtures.readKey('x25519_public.pem', 'ascii'),
|
||||
{ private: fixtures.readSync('test_x25519_privkey.pem', 'ascii'),
|
||||
public: fixtures.readSync('test_x25519_pubkey.pem', 'ascii'),
|
||||
keyType: 'x25519' },
|
||||
{ private: fixtures.readKey('x448_private.pem', 'ascii'),
|
||||
public: fixtures.readKey('x448_public.pem', 'ascii'),
|
||||
keyType: 'x448' },
|
||||
{ private: fixtures.readSync('test_x448_privkey.pem', 'ascii'),
|
||||
public: fixtures.readSync('test_x448_pubkey.pem', 'ascii'),
|
||||
keyType: 'x448' }
|
||||
].forEach((info) => {
|
||||
const keyType = info.keyType;
|
||||
|
||||
|
||||
@@ -11,19 +11,18 @@ const constants = crypto.constants;
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
// Test certificates
|
||||
const certPem = fixtures.readKey('rsa_cert.crt');
|
||||
const keyPem = fixtures.readKey('rsa_private.pem');
|
||||
const rsaKeySize = 2048;
|
||||
const rsaPubPem = fixtures.readKey('rsa_public.pem', 'ascii');
|
||||
const rsaKeyPem = fixtures.readKey('rsa_private.pem', 'ascii');
|
||||
const rsaKeyPemEncrypted = fixtures.readKey('rsa_private_encrypted.pem',
|
||||
'ascii');
|
||||
const dsaPubPem = fixtures.readKey('dsa_public.pem', 'ascii');
|
||||
const dsaKeyPem = fixtures.readKey('dsa_private.pem', 'ascii');
|
||||
const dsaKeyPemEncrypted = fixtures.readKey('dsa_private_encrypted.pem',
|
||||
'ascii');
|
||||
const rsaPkcs8KeyPem = fixtures.readKey('rsa_private_pkcs8.pem');
|
||||
const dsaPkcs8KeyPem = fixtures.readKey('dsa_private_pkcs8.pem');
|
||||
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
||||
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
|
||||
const rsaPubPem = fixtures.readSync('test_rsa_pubkey.pem', 'ascii');
|
||||
const rsaKeyPem = fixtures.readSync('test_rsa_privkey.pem', 'ascii');
|
||||
const rsaKeyPemEncrypted = fixtures.readSync('test_rsa_privkey_encrypted.pem',
|
||||
'ascii');
|
||||
const dsaPubPem = fixtures.readSync('test_dsa_pubkey.pem', 'ascii');
|
||||
const dsaKeyPem = fixtures.readSync('test_dsa_privkey.pem', 'ascii');
|
||||
const dsaKeyPemEncrypted = fixtures.readSync('test_dsa_privkey_encrypted.pem',
|
||||
'ascii');
|
||||
const rsaPkcs8KeyPem = fixtures.readSync('test_rsa_pkcs8_privkey.pem');
|
||||
const dsaPkcs8KeyPem = fixtures.readSync('test_dsa_pkcs8_privkey.pem');
|
||||
|
||||
const decryptError = {
|
||||
message: 'error:06065064:digital envelope routines:EVP_DecryptFinal_ex:' +
|
||||
@@ -97,7 +96,7 @@ const decryptError = {
|
||||
assert.strictEqual(decryptedBufferWithPassword.toString(), input);
|
||||
|
||||
// Now with RSA_NO_PADDING. Plaintext needs to match key size.
|
||||
const plaintext = 'x'.repeat(rsaKeySize / 8);
|
||||
const plaintext = 'x'.repeat(128);
|
||||
encryptedBuffer = crypto.privateEncrypt({
|
||||
padding: crypto.constants.RSA_NO_PADDING,
|
||||
key: rsaKeyPemEncrypted,
|
||||
@@ -154,7 +153,7 @@ const decryptError = {
|
||||
}
|
||||
|
||||
function test_rsa(padding) {
|
||||
const size = (padding === 'RSA_NO_PADDING') ? rsaKeySize / 8 : 32;
|
||||
const size = (padding === 'RSA_NO_PADDING') ? 1024 / 8 : 32;
|
||||
const input = Buffer.allocUnsafe(size);
|
||||
for (let i = 0; i < input.length; i++)
|
||||
input[i] = (i * 7 + 11) & 0xff;
|
||||
@@ -190,10 +189,12 @@ let rsaVerify = crypto.createVerify('SHA1');
|
||||
assert.ok(rsaSign);
|
||||
assert.ok(rsaVerify);
|
||||
|
||||
const expectedSignature = fixtures.readKey(
|
||||
'rsa_public_sha1_signature_signedby_rsa_private_pkcs8.sha1',
|
||||
'hex'
|
||||
);
|
||||
const expectedSignature =
|
||||
'5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' +
|
||||
'8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' +
|
||||
'e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f' +
|
||||
'60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f' +
|
||||
'40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6';
|
||||
|
||||
rsaSign.update(rsaPubPem);
|
||||
let rsaSignature = rsaSign.sign(rsaKeyPem, 'hex');
|
||||
@@ -234,21 +235,23 @@ assert.throws(() => {
|
||||
// Test RSA signing and verification
|
||||
//
|
||||
{
|
||||
const privateKey = fixtures.readKey('rsa_private_b.pem');
|
||||
const publicKey = fixtures.readKey('rsa_public_b.pem');
|
||||
const privateKey = fixtures.readSync('test_rsa_privkey_2.pem');
|
||||
const publicKey = fixtures.readSync('test_rsa_pubkey_2.pem');
|
||||
|
||||
const input = 'I AM THE WALRUS';
|
||||
|
||||
const signature = fixtures.readKey(
|
||||
'I_AM_THE_WALRUS_sha256_signature_signedby_rsa_private_b.sha256',
|
||||
'hex'
|
||||
);
|
||||
const signature =
|
||||
'79d59d34f56d0e94aa6a3e306882b52ed4191f07521f25f505a078dc2f89' +
|
||||
'396e0c8ac89e996fde5717f4cb89199d8fec249961fcb07b74cd3d2a4ffa' +
|
||||
'235417b69618e4bcd76b97e29975b7ce862299410e1b522a328e44ac9bb2' +
|
||||
'8195e0268da7eda23d9825ac43c724e86ceeee0d0d4465678652ccaf6501' +
|
||||
'0ddfb299bedeb1ad';
|
||||
|
||||
const sign = crypto.createSign('SHA256');
|
||||
sign.update(input);
|
||||
|
||||
const output = sign.sign(privateKey, 'hex');
|
||||
assert.strictEqual(output, signature);
|
||||
assert.strictEqual(signature, output);
|
||||
|
||||
const verify = crypto.createVerify('SHA256');
|
||||
verify.update(input);
|
||||
@@ -260,7 +263,7 @@ assert.throws(() => {
|
||||
sign2.update(input);
|
||||
|
||||
const output2 = sign2.sign(privateKey, 'hex');
|
||||
assert.strictEqual(output2, signature);
|
||||
assert.strictEqual(signature, output2);
|
||||
|
||||
const verify2 = crypto.createVerify('SHA256');
|
||||
verify2.update(input);
|
||||
|
||||
@@ -11,9 +11,9 @@ const crypto = require('crypto');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
// Test certificates
|
||||
const certPem = fixtures.readKey('rsa_cert.crt');
|
||||
const keyPem = fixtures.readKey('rsa_private.pem');
|
||||
const keySize = 2048;
|
||||
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
||||
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
|
||||
const modSize = 1024;
|
||||
|
||||
{
|
||||
const Sign = crypto.Sign;
|
||||
@@ -152,7 +152,7 @@ common.expectsError(
|
||||
{
|
||||
function testPSS(algo, hLen) {
|
||||
// Maximum permissible salt length
|
||||
const max = keySize / 8 - hLen - 2;
|
||||
const max = modSize / 8 - hLen - 2;
|
||||
|
||||
function getEffectiveSaltLength(saltLength) {
|
||||
switch (saltLength) {
|
||||
@@ -418,12 +418,12 @@ common.expectsError(
|
||||
}
|
||||
|
||||
[
|
||||
{ private: fixtures.readKey('ed25519_private.pem', 'ascii'),
|
||||
public: fixtures.readKey('ed25519_public.pem', 'ascii'),
|
||||
{ private: fixtures.readSync('test_ed25519_privkey.pem', 'ascii'),
|
||||
public: fixtures.readSync('test_ed25519_pubkey.pem', 'ascii'),
|
||||
algo: null,
|
||||
sigLen: 64 },
|
||||
{ private: fixtures.readKey('ed448_private.pem', 'ascii'),
|
||||
public: fixtures.readKey('ed448_public.pem', 'ascii'),
|
||||
{ private: fixtures.readSync('test_ed448_privkey.pem', 'ascii'),
|
||||
public: fixtures.readSync('test_ed448_pubkey.pem', 'ascii'),
|
||||
algo: null,
|
||||
sigLen: 114 },
|
||||
{ private: fixtures.readKey('rsa_private_2048.pem', 'ascii'),
|
||||
|
||||
@@ -29,7 +29,7 @@ const crypto = require('crypto');
|
||||
const tls = require('tls');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const certPem = fixtures.readKey('rsa_cert.crt');
|
||||
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
||||
|
||||
const options = {
|
||||
key: fixtures.readKey('agent1-key.pem'),
|
||||
|
||||
@@ -37,7 +37,7 @@ const tls = require('tls');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
// Test Certificates
|
||||
const certPfx = fixtures.readKey('rsa_cert.pfx');
|
||||
const certPfx = fixtures.readSync('test_cert.pfx');
|
||||
|
||||
// 'this' safety
|
||||
// https://github.com/joyent/node/issues/6690
|
||||
@@ -224,12 +224,17 @@ assert.throws(function() {
|
||||
});
|
||||
|
||||
assert.throws(function() {
|
||||
// The correct header inside `rsa_private_pkcs8_bad.pem` should have been
|
||||
// The correct header inside `test_bad_rsa_privkey.pem` should have been
|
||||
// -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----
|
||||
// instead of
|
||||
// -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY-----
|
||||
const sha1_privateKey = fixtures.readKey('rsa_private_pkcs8_bad.pem',
|
||||
'ascii');
|
||||
// It is generated in this way:
|
||||
// $ openssl genrsa -out mykey.pem 512;
|
||||
// $ openssl pkcs8 -topk8 -inform PEM -outform PEM -in mykey.pem \
|
||||
// -out private_key.pem -nocrypt;
|
||||
// Then open private_key.pem and change its header and footer.
|
||||
const sha1_privateKey = fixtures.readSync('test_bad_rsa_privkey.pem',
|
||||
'ascii');
|
||||
// This would inject errors onto OpenSSL's error stack
|
||||
crypto.createSign('sha1').sign(sha1_privateKey);
|
||||
}, (err) => {
|
||||
|
||||
@@ -30,8 +30,8 @@ const assert = require('assert');
|
||||
const https = require('https');
|
||||
|
||||
const options = {
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt')
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem')
|
||||
};
|
||||
|
||||
const server = https.createServer(options, common.mustCall(function(req, res) {
|
||||
@@ -72,7 +72,7 @@ function rejectUnauthorized() {
|
||||
function authorized() {
|
||||
const options = {
|
||||
port: server.address().port,
|
||||
ca: [fixtures.readKey('rsa_cert.crt')]
|
||||
ca: [fixtures.readSync('test_cert.pem')]
|
||||
};
|
||||
options.agent = new https.Agent(options);
|
||||
const req = https.request(options, function(res) {
|
||||
|
||||
@@ -50,8 +50,8 @@ const LIMITS = [0, 1, 2, 3, 5, 10, 16];
|
||||
|
||||
function test(next) {
|
||||
const options = {
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem'),
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
};
|
||||
|
||||
const server = https.createServer(options, (req, res) => {
|
||||
|
||||
@@ -29,8 +29,8 @@ const assert = require('assert');
|
||||
const https = require('https');
|
||||
|
||||
const options = {
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt')
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem')
|
||||
};
|
||||
|
||||
const bufSize = 1024 * 1024;
|
||||
|
||||
@@ -33,15 +33,21 @@ const https = require('https');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
const options = {
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
key: fixtures.readSync('agent.key'),
|
||||
cert: fixtures.readSync('agent.crt'),
|
||||
requestCert: true,
|
||||
rejectUnauthorized: false
|
||||
};
|
||||
|
||||
const webIdUrl = 'URI:http://example.com/#me';
|
||||
const modulus = fixtures.readKey('rsa_cert_foafssl_b.modulus', 'ascii').replace(/\n/g, '');
|
||||
const exponent = fixtures.readKey('rsa_cert_foafssl_b.exponent', 'ascii').replace(/\n/g, '');
|
||||
const modulus = 'A6F44A9C25791431214F5C87AF9E040177A8BB89AC803F7E09BBC3A5519F' +
|
||||
'349CD9B9C40BE436D0AA823A94147E26C89248ADA2BE3DD4D34E8C289646' +
|
||||
'94B2047D217B4F1299371EA93A83C89AB9440724131E65F2B0161DE9560C' +
|
||||
'DE9C13455552B2F49CF0FB00D8D77532324913F6F80FF29D0A131D29DB06' +
|
||||
'AFF8BE191B7920DC2DAE1C26EA82A47847A10391EF3BF6AABB3CC40FF821' +
|
||||
'00B03A4F0FF1809278E4DDFDA7DE954ED56DC7AD9A47EEBC37D771A366FC' +
|
||||
'60A5BCB72373BEC180649B3EFA0E9092707210B41B90032BB18BC91F2046' +
|
||||
'EBDAF1191F4A4E26D71879C4C7867B62FCD508E8CE66E82D128A71E91580' +
|
||||
'9FCF44E8DE774067F1DE5D70B9C03687';
|
||||
|
||||
const CRLF = '\r\n';
|
||||
const body = 'hello world\n';
|
||||
@@ -52,8 +58,8 @@ const server = https.createServer(options, common.mustCall(function(req, res) {
|
||||
|
||||
cert = req.connection.getPeerCertificate();
|
||||
|
||||
assert.strictEqual(cert.subjectaltname, webIdUrl);
|
||||
assert.strictEqual(cert.exponent, exponent);
|
||||
assert.strictEqual(cert.subjectaltname, 'URI:http://example.com/#me');
|
||||
assert.strictEqual(cert.exponent, '0x10001');
|
||||
assert.strictEqual(cert.modulus, modulus);
|
||||
res.writeHead(200, { 'content-type': 'text/plain' });
|
||||
res.end(body);
|
||||
@@ -63,8 +69,8 @@ server.listen(0, function() {
|
||||
const args = ['s_client',
|
||||
'-quiet',
|
||||
'-connect', `127.0.0.1:${this.address().port}`,
|
||||
'-cert', fixtures.path('keys/rsa_cert_foafssl_b.crt'),
|
||||
'-key', fixtures.path('keys/rsa_private_b.pem')];
|
||||
'-cert', fixtures.path('foafssl.crt'),
|
||||
'-key', fixtures.path('foafssl.key')];
|
||||
|
||||
const client = spawn(common.opensslCli, args);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
const https = require('https');
|
||||
|
||||
const pfx = fixtures.readKey('rsa_cert.pfx');
|
||||
const pfx = fixtures.readSync('test_cert.pfx');
|
||||
|
||||
const options = {
|
||||
host: '127.0.0.1',
|
||||
|
||||
@@ -10,8 +10,8 @@ tmpdir.refresh();
|
||||
const fixtures = require('../common/fixtures');
|
||||
const https = require('https');
|
||||
const options = {
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
key: fixtures.readKey('rsa_private.pem')
|
||||
cert: fixtures.readSync('test_cert.pem'),
|
||||
key: fixtures.readSync('test_key.pem')
|
||||
};
|
||||
|
||||
const server = https.createServer(options, common.mustCall((req, res) => {
|
||||
|
||||
@@ -15,8 +15,8 @@ const tls = require('tls');
|
||||
|
||||
const options = {
|
||||
secureOptions: SSL_OP_NO_TICKET,
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt')
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem')
|
||||
};
|
||||
|
||||
const server = tls.createServer(options, common.mustCall());
|
||||
|
||||
@@ -27,8 +27,8 @@ if (!common.hasCrypto)
|
||||
const tls = require('tls');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const cert = fixtures.readKey('rsa_cert.crt');
|
||||
const key = fixtures.readKey('rsa_private.pem');
|
||||
const cert = fixtures.readSync('test_cert.pem');
|
||||
const key = fixtures.readSync('test_key.pem');
|
||||
|
||||
const conn = tls.connect({ cert, key, port: 0 }, common.mustNotCall());
|
||||
conn.on('error', function() {});
|
||||
|
||||
@@ -29,8 +29,8 @@ const tls = require('tls');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const options = {
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt')
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem')
|
||||
};
|
||||
|
||||
const server = tls.createServer(options, function(socket) {
|
||||
@@ -80,7 +80,7 @@ function rejectUnauthorized() {
|
||||
function authorized() {
|
||||
console.log('connect authorized');
|
||||
const socket = tls.connect(server.address().port, {
|
||||
ca: [fixtures.readKey('rsa_cert.crt')],
|
||||
ca: [fixtures.readSync('test_cert.pem')],
|
||||
servername: 'localhost'
|
||||
}, common.mustCall(function() {
|
||||
console.log('... authorized');
|
||||
|
||||
@@ -49,8 +49,8 @@ const LIMITS = [0, 1, 2, 3, 5, 10, 16];
|
||||
|
||||
function test(next) {
|
||||
const options = {
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem'),
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
};
|
||||
|
||||
const server = tls.createServer(options, (conn) => {
|
||||
|
||||
@@ -30,8 +30,8 @@ const tls = require('tls');
|
||||
const net = require('net');
|
||||
|
||||
const options = {
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt')
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem')
|
||||
};
|
||||
|
||||
const server = tls.createServer(options, common.mustCall((socket) => {
|
||||
|
||||
@@ -35,8 +35,8 @@ const fixtures = require('../common/fixtures');
|
||||
// added using `once()`, i.e. can be gc'ed once that event has occurred.
|
||||
|
||||
const server = tls.createServer({
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
key: fixtures.readKey('rsa_private.pem')
|
||||
cert: fixtures.readSync('test_cert.pem'),
|
||||
key: fixtures.readSync('test_key.pem')
|
||||
}).listen(0);
|
||||
|
||||
let collected = false;
|
||||
|
||||
@@ -8,8 +8,8 @@ if (!common.hasCrypto)
|
||||
const tls = require('tls');
|
||||
const assert = require('assert');
|
||||
|
||||
const cert = fixtures.readKey('rsa_cert.crt');
|
||||
const key = fixtures.readKey('rsa_private.pem');
|
||||
const cert = fixtures.readSync('test_cert.pem');
|
||||
const key = fixtures.readSync('test_key.pem');
|
||||
|
||||
// https://github.com/nodejs/node/issues/1489
|
||||
// tls.connect(options) with no options.host should accept a cert with
|
||||
|
||||
@@ -9,9 +9,9 @@ const stream = require('stream');
|
||||
const net = require('net');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const options = { key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
ca: [ fixtures.readKey('rsa_ca.crt') ],
|
||||
const options = { key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem'),
|
||||
ca: [ fixtures.readSync('test_ca.pem') ],
|
||||
ciphers: 'AES256-GCM-SHA384' };
|
||||
const content = 'hello world';
|
||||
const recv_bufs = [];
|
||||
|
||||
@@ -18,9 +18,9 @@ tls.DEFAULT_MAX_VERSION = 'TLSv1.3';
|
||||
const CONTENT = 'Hello World';
|
||||
const tlsServer = tls.createServer(
|
||||
{
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
ca: [fixtures.readKey('rsa_ca.crt')],
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem'),
|
||||
ca: [fixtures.readSync('test_ca.pem')],
|
||||
},
|
||||
(socket) => {
|
||||
socket.on('close', common.mustCall());
|
||||
|
||||
@@ -44,8 +44,10 @@ common.expectWarning('SecurityWarning',
|
||||
'DH parameter is less than 2048 bits');
|
||||
|
||||
function loadDHParam(n) {
|
||||
const keyname = `dh${n}.pem`;
|
||||
return fixtures.readKey(keyname);
|
||||
const params = [`dh${n}.pem`];
|
||||
if (n !== 'error')
|
||||
params.unshift('keys');
|
||||
return fixtures.readSync(params);
|
||||
}
|
||||
|
||||
function test(keylen, expectedCipher, cb) {
|
||||
|
||||
@@ -28,9 +28,9 @@ const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
const tls = require('tls');
|
||||
|
||||
const options = { key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
ca: [ fixtures.readKey('rsa_ca.crt') ] };
|
||||
const options = { key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem'),
|
||||
ca: [ fixtures.readSync('test_ca.pem') ] };
|
||||
|
||||
const server = tls.createServer(options, onconnection);
|
||||
let gotChunk = false;
|
||||
|
||||
@@ -18,8 +18,8 @@ const clientConfigs = [
|
||||
|
||||
const serverConfig = {
|
||||
secureProtocol: 'TLS_method',
|
||||
key: fixtures.readKey('agent2-key.pem'),
|
||||
cert: fixtures.readKey('agent2-cert.pem')
|
||||
key: fixtures.readSync('/keys/agent2-key.pem'),
|
||||
cert: fixtures.readSync('/keys/agent2-cert.pem')
|
||||
};
|
||||
|
||||
const server = tls.createServer(serverConfig, common.mustCall(function() {
|
||||
|
||||
@@ -21,8 +21,8 @@ if (process.argv[2] === 'child') {
|
||||
const { Duplex } = require('stream');
|
||||
const { mustCall } = common;
|
||||
|
||||
const cert = fixtures.readKey('rsa_cert.crt');
|
||||
const key = fixtures.readKey('rsa_private.pem');
|
||||
const cert = fixtures.readSync('test_cert.pem');
|
||||
const key = fixtures.readSync('test_key.pem');
|
||||
|
||||
net.createServer(mustCall(onplaintext)).listen(0, mustCall(onlisten));
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ const tls = require('tls');
|
||||
const net = require('net');
|
||||
|
||||
const options = {
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt')
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem')
|
||||
};
|
||||
|
||||
const bonkers = Buffer.alloc(1024 * 1024, 42);
|
||||
|
||||
@@ -32,8 +32,8 @@ const tls = require('tls');
|
||||
const net = require('net');
|
||||
|
||||
const options = {
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt')
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem')
|
||||
};
|
||||
|
||||
const body = 'A'.repeat(40000);
|
||||
|
||||
@@ -30,9 +30,9 @@ const tls = require('tls');
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const options = { key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
ca: [ fixtures.readKey('rsa_ca.crt') ] };
|
||||
const options = { key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem'),
|
||||
ca: [ fixtures.readSync('test_ca.pem') ] };
|
||||
|
||||
const writes = [
|
||||
'some server data',
|
||||
|
||||
@@ -9,8 +9,8 @@ const tls = require('tls');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const server = tls.createServer({
|
||||
key: fixtures.readKey('agent2-key.pem'),
|
||||
cert: fixtures.readKey('agent2-cert.pem'),
|
||||
key: fixtures.readSync('/keys/agent2-key.pem'),
|
||||
cert: fixtures.readSync('/keys/agent2-cert.pem'),
|
||||
// Amount of keylog events depends on negotiated protocol
|
||||
// version, so force a specific one:
|
||||
minVersion: 'TLSv1.3',
|
||||
|
||||
@@ -29,8 +29,8 @@ function mkServer(lib, tcp, cb) {
|
||||
const args = [handler];
|
||||
if (lib === tls) {
|
||||
args.unshift({
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
key: fixtures.readKey('rsa_private.pem')
|
||||
cert: fixtures.readSync('test_cert.pem'),
|
||||
key: fixtures.readSync('test_key.pem')
|
||||
});
|
||||
}
|
||||
const server = lib.createServer(...args);
|
||||
|
||||
@@ -11,8 +11,8 @@ const tls = require('tls');
|
||||
const spawn = require('child_process').spawn;
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const cert = fixtures.readKey('rsa_cert.crt');
|
||||
const key = fixtures.readKey('rsa_private.pem');
|
||||
const cert = fixtures.readSync('test_cert.pem');
|
||||
const key = fixtures.readSync('test_key.pem');
|
||||
const server = tls.createServer({ cert, key }, common.mustNotCall());
|
||||
const errors = [];
|
||||
let stderr = '';
|
||||
|
||||
@@ -28,9 +28,9 @@ const assert = require('assert');
|
||||
const tls = require('tls');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const passKey = fixtures.readKey('rsa_private_encrypted.pem');
|
||||
const rawKey = fixtures.readKey('rsa_private.pem');
|
||||
const cert = fixtures.readKey('rsa_cert.crt');
|
||||
const passKey = fixtures.readSync('pass-key.pem');
|
||||
const rawKey = fixtures.readSync('raw-key.pem');
|
||||
const cert = fixtures.readSync('pass-cert.pem');
|
||||
|
||||
assert(Buffer.isBuffer(passKey));
|
||||
assert(Buffer.isBuffer(cert));
|
||||
@@ -39,7 +39,7 @@ assert.strictEqual(typeof cert.toString(), 'string');
|
||||
|
||||
const server = tls.Server({
|
||||
key: passKey,
|
||||
passphrase: 'password',
|
||||
passphrase: 'passphrase',
|
||||
cert: cert,
|
||||
ca: [cert],
|
||||
requestCert: true,
|
||||
@@ -53,7 +53,7 @@ server.listen(0, common.mustCall(function() {
|
||||
tls.connect({
|
||||
port: this.address().port,
|
||||
key: passKey,
|
||||
passphrase: 'password',
|
||||
passphrase: 'passphrase',
|
||||
cert: cert,
|
||||
rejectUnauthorized: false
|
||||
}, common.mustCall());
|
||||
@@ -77,7 +77,7 @@ server.listen(0, common.mustCall(function() {
|
||||
tls.connect({
|
||||
port: this.address().port,
|
||||
key: [passKey],
|
||||
passphrase: 'password',
|
||||
passphrase: 'passphrase',
|
||||
cert: [cert],
|
||||
rejectUnauthorized: false
|
||||
}, common.mustCall());
|
||||
@@ -101,7 +101,7 @@ server.listen(0, common.mustCall(function() {
|
||||
tls.connect({
|
||||
port: this.address().port,
|
||||
key: passKey.toString(),
|
||||
passphrase: 'password',
|
||||
passphrase: 'passphrase',
|
||||
cert: cert.toString(),
|
||||
rejectUnauthorized: false
|
||||
}, common.mustCall());
|
||||
@@ -125,7 +125,7 @@ server.listen(0, common.mustCall(function() {
|
||||
tls.connect({
|
||||
port: this.address().port,
|
||||
key: [passKey.toString()],
|
||||
passphrase: 'password',
|
||||
passphrase: 'passphrase',
|
||||
cert: [cert.toString()],
|
||||
rejectUnauthorized: false
|
||||
}, common.mustCall());
|
||||
@@ -148,14 +148,14 @@ server.listen(0, common.mustCall(function() {
|
||||
// Object[]
|
||||
tls.connect({
|
||||
port: this.address().port,
|
||||
key: [{ pem: passKey, passphrase: 'password' }],
|
||||
key: [{ pem: passKey, passphrase: 'passphrase' }],
|
||||
cert: cert,
|
||||
rejectUnauthorized: false
|
||||
}, common.mustCall());
|
||||
|
||||
tls.connect({
|
||||
port: this.address().port,
|
||||
key: [{ pem: passKey, passphrase: 'password' }],
|
||||
key: [{ pem: passKey, passphrase: 'passphrase' }],
|
||||
passphrase: 'ignored',
|
||||
cert: cert,
|
||||
rejectUnauthorized: false
|
||||
@@ -164,14 +164,14 @@ server.listen(0, common.mustCall(function() {
|
||||
tls.connect({
|
||||
port: this.address().port,
|
||||
key: [{ pem: passKey }],
|
||||
passphrase: 'password',
|
||||
passphrase: 'passphrase',
|
||||
cert: cert,
|
||||
rejectUnauthorized: false
|
||||
}, common.mustCall());
|
||||
|
||||
tls.connect({
|
||||
port: this.address().port,
|
||||
key: [{ pem: passKey.toString(), passphrase: 'password' }],
|
||||
key: [{ pem: passKey.toString(), passphrase: 'passphrase' }],
|
||||
cert: cert,
|
||||
rejectUnauthorized: false
|
||||
}, common.mustCall());
|
||||
@@ -288,7 +288,7 @@ assert.throws(function() {
|
||||
tls.connect({
|
||||
port: server.address().port,
|
||||
key: [{ pem: passKey, passphrase: 'invalid' }],
|
||||
passphrase: 'password', // Valid but unused
|
||||
passphrase: 'passphrase', // Valid but unused
|
||||
cert: cert,
|
||||
rejectUnauthorized: false
|
||||
});
|
||||
|
||||
@@ -32,8 +32,8 @@ const tls = require('tls');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const options = {
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt')
|
||||
key: fixtures.readSync('test_key.pem'),
|
||||
cert: fixtures.readSync('test_cert.pem')
|
||||
};
|
||||
|
||||
const bufSize = 1024 * 1024;
|
||||
|
||||
@@ -29,8 +29,8 @@ const tls = require('tls');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const options = {
|
||||
key: fixtures.readKey('rsa_private.pem'),
|
||||
cert: fixtures.readKey('rsa_cert.crt')
|
||||
key: fixtures.readSync('agent.key'),
|
||||
cert: fixtures.readSync('multi-alice.crt')
|
||||
};
|
||||
|
||||
const server = tls.createServer(options, function(cleartext) {
|
||||
@@ -42,7 +42,7 @@ server.once('secureConnection', common.mustCall(function(socket) {
|
||||
// The server's local cert is the client's peer cert.
|
||||
assert.deepStrictEqual(
|
||||
cert.subject.OU,
|
||||
['Test TLS Certificate', 'Engineering']
|
||||
['Information Technology', 'Engineering', 'Marketing']
|
||||
);
|
||||
}));
|
||||
|
||||
@@ -54,7 +54,7 @@ server.listen(0, common.mustCall(function() {
|
||||
const peerCert = socket.getPeerCertificate();
|
||||
assert.deepStrictEqual(
|
||||
peerCert.subject.OU,
|
||||
['Test TLS Certificate', 'Engineering']
|
||||
['Information Technology', 'Engineering', 'Marketing']
|
||||
);
|
||||
server.close();
|
||||
}));
|
||||
|
||||
@@ -9,8 +9,8 @@ const tls = require('tls');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const sslcontext = tls.createSecureContext({
|
||||
cert: fixtures.readKey('rsa_cert.crt'),
|
||||
key: fixtures.readKey('rsa_private.pem')
|
||||
cert: fixtures.readSync('test_cert.pem'),
|
||||
key: fixtures.readSync('test_key.pem')
|
||||
});
|
||||
|
||||
const pair = tls.createSecurePair(sslcontext, true, false, false, {
|
||||
|
||||
@@ -33,8 +33,8 @@ const net = require('net');
|
||||
const spawn = require('child_process').spawn;
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const key = fixtures.readKey('rsa_private.pem');
|
||||
const cert = fixtures.readKey('rsa_cert.crt');
|
||||
const key = fixtures.readSync('agent.key').toString();
|
||||
const cert = fixtures.readSync('agent.crt').toString();
|
||||
|
||||
function log(a) {
|
||||
console.error(`***server*** ${a}`);
|
||||
|
||||
@@ -41,8 +41,8 @@ doTest({ tickets: false }, function() {
|
||||
});
|
||||
|
||||
function doTest(testOptions, callback) {
|
||||
const key = fixtures.readKey('rsa_private.pem');
|
||||
const cert = fixtures.readKey('rsa_cert.crt');
|
||||
const key = fixtures.readSync('agent.key');
|
||||
const cert = fixtures.readSync('agent.crt');
|
||||
const options = {
|
||||
key,
|
||||
cert,
|
||||
@@ -101,8 +101,8 @@ function doTest(testOptions, callback) {
|
||||
'-tls1',
|
||||
'-connect', `localhost:${this.address().port}`,
|
||||
'-servername', 'ohgod',
|
||||
'-key', fixtures.path('keys/rsa_private.pem'),
|
||||
'-cert', fixtures.path('keys/rsa_cert.crt'),
|
||||
'-key', fixtures.path('agent.key'),
|
||||
'-cert', fixtures.path('agent.crt'),
|
||||
'-reconnect'
|
||||
].concat(testOptions.tickets ? [] : '-no_ticket');
|
||||
|
||||
|
||||
@@ -94,8 +94,8 @@ if (cluster.isMaster) {
|
||||
return;
|
||||
}
|
||||
|
||||
const key = fixtures.readKey('rsa_private.pem');
|
||||
const cert = fixtures.readKey('rsa_cert.crt');
|
||||
const key = fixtures.readSync('agent.key');
|
||||
const cert = fixtures.readSync('agent.crt');
|
||||
|
||||
const options = { key, cert };
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ if (!common.hasCrypto)
|
||||
const tls = require('tls');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const cert = fixtures.readKey('rsa_cert.crt');
|
||||
const key = fixtures.readKey('rsa_private.pem');
|
||||
const cert = fixtures.readSync('test_cert.pem');
|
||||
const key = fixtures.readSync('test_key.pem');
|
||||
|
||||
const server = tls.createServer({
|
||||
cert,
|
||||
|
||||
@@ -4,7 +4,7 @@ const assert = require('assert');
|
||||
const child_process = require('child_process');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const wrong_script = fixtures.path('keys/rsa_cert.crt');
|
||||
const wrong_script = fixtures.path('cert.pem');
|
||||
|
||||
const p = child_process.spawn(process.execPath, [
|
||||
'-e',
|
||||
|
||||
Reference in new issue
Block a user