| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1327,6 +1327,7 @@ LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \ | |||
| 1327 | 1327 | test/cctest/*.h \ | |
| 1328 | 1328 | test/embedding/*.cc \ | |
| 1329 | 1329 | test/embedding/*.h \ | |
| 1330 | + test/fixtures/*.c \ | ||
| 1330 | 1331 | test/js-native-api/*/*.cc \ | |
| 1331 | 1332 | test/js-native-api/*/*.h \ | |
| 1332 | 1333 | test/node-api/*/*.cc \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1391,5 +1391,31 @@ | |||
| 1391 | 1391 | }, | |
| 1392 | 1392 | ] | |
| 1393 | 1393 | }], # end aix section | |
| 1394 | + # TODO(RaisinTen): Enable this to build on other platforms as well. | ||
| 1395 | + ['(OS=="mac" or (OS=="linux" and target_arch=="x64")) and \ | ||
| 1396 | + node_use_openssl=="true"', { | ||
| 1397 | + 'targets': [ | ||
| 1398 | + { | ||
| 1399 | + 'target_name': 'test_crypto_engine', | ||
| 1400 | + 'type': 'shared_library', | ||
| 1401 | + 'include_dirs': ['deps/openssl/openssl/include'], | ||
| 1402 | + 'sources': ['test/fixtures/test_crypto_engine.c'], | ||
| 1403 | + 'conditions': [ | ||
| 1404 | + ['OS=="mac"', { | ||
| 1405 | + 'dependencies': ['deps/openssl/openssl.gyp:openssl'], | ||
| 1406 | + 'xcode_settings': { | ||
| 1407 | + 'OTHER_CFLAGS': ['-Wno-deprecated-declarations'], | ||
| 1408 | + }, | ||
| 1409 | + }], | ||
| 1410 | + ['OS=="linux" and target_arch=="x64"', { | ||
| 1411 | + 'cflags': [ | ||
| 1412 | + '-Wno-deprecated-declarations', | ||
| 1413 | + '-fPIC', | ||
| 1414 | + ], | ||
| 1415 | + }], | ||
| 1416 | + ], | ||
| 1417 | + }, # test_crypto_engine | ||
| 1418 | + ], # end targets | ||
| 1419 | + }], # end node_use_openssl section | ||
| 1394 | 1420 | ], # end conditions block | |
| 1395 | 1421 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + #include <openssl/engine.h> | ||
| 2 | + | ||
| 3 | + #include <stdio.h> | ||
| 4 | + | ||
| 5 | + int bind(ENGINE* e, const char* id) { | ||
| 6 | + if (ENGINE_set_id(e, "libtest_crypto_engine") == 0) { | ||
| 7 | + fprintf(stderr, "ENGINE_set_id() failed.\n"); | ||
| 8 | + return 0; | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + if (ENGINE_set_name(e, "A test crypto engine") == 0) { | ||
| 12 | + fprintf(stderr, "ENGINE_set_name() failed.\n"); | ||
| 13 | + return 0; | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + return 1; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + IMPLEMENT_DYNAMIC_BIND_FN(bind) | ||
| 20 | + IMPLEMENT_DYNAMIC_CHECK_FN() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,43 +1,60 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | + if (!common.hasCrypto) common.skip('missing crypto'); | ||
| 3 | 4 | ||
| 4 | - if (!common.hasCrypto) | ||
| 5 | - common.skip('missing crypto'); | ||
| 5 | + // This tests crypto.setEngine(). | ||
| 6 | 6 | ||
| 7 | 7 | const assert = require('assert'); | |
| 8 | 8 | const crypto = require('crypto'); | |
| 9 | - const invalidEngineName = 'xxx'; | ||
| 10 | - | ||
| 11 | - assert.throws( | ||
| 12 | - () => crypto.setEngine(true), | ||
| 13 | - { | ||
| 14 | - code: 'ERR_INVALID_ARG_TYPE', | ||
| 15 | - name: 'TypeError', | ||
| 16 | - message: 'The "id" argument must be of type string. Received type boolean' + | ||
| 17 | - ' (true)' | ||
| 18 | - }); | ||
| 19 | - | ||
| 20 | - assert.throws( | ||
| 21 | - () => crypto.setEngine('/path/to/engine', 'notANumber'), | ||
| 22 | - { | ||
| 23 | - code: 'ERR_INVALID_ARG_TYPE', | ||
| 24 | - name: 'TypeError', | ||
| 25 | - message: 'The "flags" argument must be of type number. Received type' + | ||
| 26 | - " string ('notANumber')" | ||
| 27 | - }); | ||
| 28 | - | ||
| 29 | - assert.throws( | ||
| 30 | - () => crypto.setEngine(invalidEngineName), | ||
| 31 | - { | ||
| 32 | - code: 'ERR_CRYPTO_ENGINE_UNKNOWN', | ||
| 33 | - name: 'Error', | ||
| 34 | - message: `Engine "${invalidEngineName}" was not found` | ||
| 35 | - }); | ||
| 36 | - | ||
| 37 | - assert.throws( | ||
| 38 | - () => crypto.setEngine(invalidEngineName, crypto.constants.ENGINE_METHOD_RSA), | ||
| 39 | - { | ||
| 40 | - code: 'ERR_CRYPTO_ENGINE_UNKNOWN', | ||
| 41 | - name: 'Error', | ||
| 42 | - message: `Engine "${invalidEngineName}" was not found` | ||
| 43 | - }); | ||
| 9 | + const fs = require('fs'); | ||
| 10 | + const path = require('path'); | ||
| 11 | + | ||
| 12 | + assert.throws(() => crypto.setEngine(true), /ERR_INVALID_ARG_TYPE/); | ||
| 13 | + assert.throws(() => crypto.setEngine('/path/to/engine', 'notANumber'), | ||
| 14 | + /ERR_INVALID_ARG_TYPE/); | ||
| 15 | + | ||
| 16 | + { | ||
| 17 | + const invalidEngineName = 'xxx'; | ||
| 18 | + assert.throws(() => crypto.setEngine(invalidEngineName), | ||
| 19 | + /ERR_CRYPTO_ENGINE_UNKNOWN/); | ||
| 20 | + assert.throws(() => crypto.setEngine(invalidEngineName, | ||
| 21 | + crypto.constants.ENGINE_METHOD_RSA), | ||
| 22 | + /ERR_CRYPTO_ENGINE_UNKNOWN/); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + crypto.setEngine('dynamic'); | ||
| 26 | + crypto.setEngine('dynamic'); | ||
| 27 | + | ||
| 28 | + crypto.setEngine('dynamic', crypto.constants.ENGINE_METHOD_RSA); | ||
| 29 | + crypto.setEngine('dynamic', crypto.constants.ENGINE_METHOD_RSA); | ||
| 30 | + | ||
| 31 | + { | ||
| 32 | + const engineName = 'test_crypto_engine'; | ||
| 33 | + let engineLib; | ||
| 34 | + if (common.isOSX) | ||
| 35 | + engineLib = `lib${engineName}.dylib`; | ||
| 36 | + else if (common.isLinux && process.arch === 'x64') | ||
| 37 | + engineLib = `lib${engineName}.so`; | ||
| 38 | + | ||
| 39 | + if (engineLib !== undefined) { | ||
| 40 | + const execDir = path.dirname(process.execPath); | ||
| 41 | + const enginePath = path.join(execDir, engineLib); | ||
| 42 | + const engineId = path.parse(engineLib).name; | ||
| 43 | + | ||
| 44 | + fs.accessSync(enginePath); | ||
| 45 | + | ||
| 46 | + crypto.setEngine(enginePath); | ||
| 47 | + crypto.setEngine(enginePath); | ||
| 48 | + | ||
| 49 | + crypto.setEngine(enginePath, crypto.constants.ENGINE_METHOD_RSA); | ||
| 50 | + crypto.setEngine(enginePath, crypto.constants.ENGINE_METHOD_RSA); | ||
| 51 | + | ||
| 52 | + process.env.OPENSSL_ENGINES = execDir; | ||
| 53 | + | ||
| 54 | + crypto.setEngine(engineId); | ||
| 55 | + crypto.setEngine(engineId); | ||
| 56 | + | ||
| 57 | + crypto.setEngine(engineId, crypto.constants.ENGINE_METHOD_RSA); | ||
| 58 | + crypto.setEngine(engineId, crypto.constants.ENGINE_METHOD_RSA); | ||
| 59 | + } | ||
| 60 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ if (typeof require === 'undefined') { | |||
| 5 | 5 | } | |
| 6 | 6 | ||
| 7 | 7 | const path = require('path'); | |
| 8 | - const { Worker } = require('worker_threads'); | ||
| 8 | + const { Worker, SHARE_ENV } = require('worker_threads'); | ||
| 9 | 9 | ||
| 10 | - new Worker(path.resolve(process.cwd(), process.argv[2])) | ||
| 10 | + new Worker(path.resolve(process.cwd(), process.argv[2]), { env: SHARE_ENV }) | ||
| 11 | 11 | .on('exit', (code) => process.exitCode = code); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments