| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4652dfd commit ef6c86c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ if (!common.opensslCli) | |||
| 12 | 12 | ||
| 13 | 13 | const assert = require('assert'); | |
| 14 | 14 | const tls = require('tls'); | |
| 15 | - const spawn = require('child_process').spawn; | ||
| 15 | + const { execFile } = require('child_process'); | ||
| 16 | 16 | const fixtures = require('../common/fixtures'); | |
| 17 | 17 | ||
| 18 | 18 | function loadPEM(n) { | |
@@ -29,49 +29,33 @@ const options = { | |||
| 29 | 29 | ||
| 30 | 30 | const reply = 'I AM THE WALRUS'; // Something recognizable | |
| 31 | 31 | ||
| 32 | - const server = tls.createServer(options, function(conn) { | ||
| 32 | + const server = tls.createServer(options, (conn) => { | ||
| 33 | 33 | conn.end(reply); | |
| 34 | - }); | ||
| 35 | - | ||
| 36 | - let gotReply = false; | ||
| 37 | - | ||
| 38 | - server.listen(0, function() { | ||
| 34 | + }).listen(0, common.mustCall(() => { | ||
| 39 | 35 | const args = ['s_client', | |
| 40 | 36 | '-cipher', `${options.ciphers}`, | |
| 41 | - '-connect', `127.0.0.1:${this.address().port}`]; | ||
| 42 | - | ||
| 43 | - const client = spawn(common.opensslCli, args); | ||
| 44 | - | ||
| 45 | - client.stdout.on('data', function(data) { | ||
| 46 | - const message = data.toString(); | ||
| 47 | - if (message.includes(reply)) | ||
| 48 | - gotReply = true; | ||
| 49 | - }); | ||
| 37 | + '-connect', `127.0.0.1:${server.address().port}`]; | ||
| 50 | 38 | ||
| 51 | - client.on('exit', function(code) { | ||
| 52 | - assert.strictEqual(code, 0); | ||
| 39 | + execFile(common.opensslCli, args, common.mustSucceed((stdout) => { | ||
| 40 | + assert(stdout.includes(reply)); | ||
| 53 | 41 | server.close(); | |
| 54 | - }); | ||
| 55 | - | ||
| 56 | - client.on('error', assert.ifError); | ||
| 57 | - }); | ||
| 42 | + })); | ||
| 43 | + })); | ||
| 58 | 44 | ||
| 59 | - process.on('exit', function() { | ||
| 60 | - assert.ok(gotReply); | ||
| 61 | - | ||
| 62 | - // Some of unsupported curves | ||
| 45 | + { | ||
| 46 | + // Some unsupported curves. | ||
| 63 | 47 | const unsupportedCurves = [ | |
| 64 | 48 | 'wap-wsg-idm-ecid-wtls1', | |
| 65 | 49 | 'c2pnb163v1', | |
| 66 | 50 | 'prime192v3', | |
| 67 | 51 | ]; | |
| 68 | 52 | ||
| 69 | - // Brainpool is not supported in FIPS mode | ||
| 53 | + // Brainpool is not supported in FIPS mode. | ||
| 70 | 54 | if (common.hasFipsCrypto) | |
| 71 | 55 | unsupportedCurves.push('brainpoolP256r1'); | |
| 72 | 56 | ||
| 73 | 57 | unsupportedCurves.forEach((ecdhCurve) => { | |
| 74 | 58 | assert.throws(() => tls.createServer({ ecdhCurve }), | |
| 75 | 59 | /Error: Failed to set ECDH curve/); | |
| 76 | 60 | }); | |
| 77 | - }); | ||
| 61 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments