| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a54090b commit 82017c9
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,50 +11,59 @@ const crypto = require('crypto'); | |||
| 11 | 11 | const fs = require('fs'); | |
| 12 | 12 | const path = require('path'); | |
| 13 | 13 | ||
| 14 | + // Engine support in OpenSSL is checked later on. | ||
| 15 | + let hasEngineSupport = true; | ||
| 14 | 16 | ||
| 15 | - assert.throws(() => crypto.setEngine(true), /ERR_INVALID_ARG_TYPE/); | ||
| 17 | + assert.throws(() => crypto.setEngine(true), /ERR_INVALID_ARG_TYPE|ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED/); | ||
| 16 | 18 | assert.throws(() => crypto.setEngine('/path/to/engine', 'notANumber'), | |
| 17 | 19 | /ERR_INVALID_ARG_TYPE/); | |
| 18 | 20 | ||
| 19 | 21 | { | |
| 20 | 22 | const invalidEngineName = 'xxx'; | |
| 21 | 23 | assert.throws(() => crypto.setEngine(invalidEngineName), | |
| 22 | - /ERR_CRYPTO_ENGINE_UNKNOWN/); | ||
| 24 | + /ERR_CRYPTO_ENGINE_UNKNOWN|ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED/); | ||
| 23 | 25 | assert.throws(() => crypto.setEngine(invalidEngineName, | |
| 24 | 26 | crypto.constants.ENGINE_METHOD_RSA), | |
| 25 | - /ERR_CRYPTO_ENGINE_UNKNOWN/); | ||
| 27 | + /ERR_CRYPTO_ENGINE_UNKNOWN|ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED/); | ||
| 26 | 28 | } | |
| 27 | 29 | ||
| 28 | - crypto.setEngine('dynamic'); | ||
| 29 | - crypto.setEngine('dynamic'); | ||
| 30 | + try { | ||
| 31 | + crypto.setEngine('dynamic'); | ||
| 32 | + crypto.setEngine('dynamic'); | ||
| 30 | 33 | ||
| 31 | - crypto.setEngine('dynamic', crypto.constants.ENGINE_METHOD_RSA); | ||
| 32 | - crypto.setEngine('dynamic', crypto.constants.ENGINE_METHOD_RSA); | ||
| 34 | + crypto.setEngine('dynamic', crypto.constants.ENGINE_METHOD_RSA); | ||
| 35 | + crypto.setEngine('dynamic', crypto.constants.ENGINE_METHOD_RSA); | ||
| 36 | + } catch (err) { | ||
| 37 | + assert.strictEqual(err.code, 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED'); | ||
| 38 | + hasEngineSupport = false; | ||
| 39 | + } | ||
| 33 | 40 | ||
| 34 | - const engine = path.join(__dirname, | ||
| 35 | - `/build/${common.buildType}/testsetengine.engine`); | ||
| 41 | + if (hasEngineSupport) { | ||
| 42 | + const engine = path.join(__dirname, | ||
| 43 | + `/build/${common.buildType}/testsetengine.engine`); | ||
| 36 | 44 | ||
| 37 | - if (!fs.existsSync(engine)) | ||
| 38 | - common.skip('no engine'); | ||
| 45 | + if (!fs.existsSync(engine)) | ||
| 46 | + common.skip('no engine'); | ||
| 39 | 47 | ||
| 40 | - { | ||
| 41 | - const engineId = path.parse(engine).name; | ||
| 42 | - const execDir = path.parse(engine).dir; | ||
| 48 | + { | ||
| 49 | + const engineId = path.parse(engine).name; | ||
| 50 | + const execDir = path.parse(engine).dir; | ||
| 43 | 51 | ||
| 44 | - crypto.setEngine(engine); | ||
| 45 | - // OpenSSL 3.0.1 and 1.1.1m now throw errors if an engine is loaded again | ||
| 46 | - // with a duplicate absolute path. | ||
| 47 | - // TODO(richardlau): figure out why this fails on macOS but not Linux. | ||
| 48 | - // crypto.setEngine(engine); | ||
| 52 | + crypto.setEngine(engine); | ||
| 53 | + // OpenSSL 3.0.1 and 1.1.1m now throw errors if an engine is loaded again | ||
| 54 | + // with a duplicate absolute path. | ||
| 55 | + // TODO(richardlau): figure out why this fails on macOS but not Linux. | ||
| 56 | + // crypto.setEngine(engine); | ||
| 49 | 57 | ||
| 50 | - // crypto.setEngine(engine, crypto.constants.ENGINE_METHOD_RSA); | ||
| 51 | - // crypto.setEngine(engine, crypto.constants.ENGINE_METHOD_RSA); | ||
| 58 | + // crypto.setEngine(engine, crypto.constants.ENGINE_METHOD_RSA); | ||
| 59 | + // crypto.setEngine(engine, crypto.constants.ENGINE_METHOD_RSA); | ||
| 52 | 60 | ||
| 53 | - process.env.OPENSSL_ENGINES = execDir; | ||
| 61 | + process.env.OPENSSL_ENGINES = execDir; | ||
| 54 | 62 | ||
| 55 | - crypto.setEngine(engineId); | ||
| 56 | - crypto.setEngine(engineId); | ||
| 63 | + crypto.setEngine(engineId); | ||
| 64 | + crypto.setEngine(engineId); | ||
| 57 | 65 | ||
| 58 | - crypto.setEngine(engineId, crypto.constants.ENGINE_METHOD_RSA); | ||
| 59 | - crypto.setEngine(engineId, crypto.constants.ENGINE_METHOD_RSA); | ||
| 66 | + crypto.setEngine(engineId, crypto.constants.ENGINE_METHOD_RSA); | ||
| 67 | + crypto.setEngine(engineId, crypto.constants.ENGINE_METHOD_RSA); | ||
| 68 | + } | ||
| 60 | 69 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments