|
@ -19,17 +19,18 @@ |
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
|
if (!process.versions.openssl) { |
|
|
var common = require('../common'); |
|
|
console.error('Skipping because node compiled without OpenSSL.'); |
|
|
|
|
|
|
|
|
if (!common.opensslCli) { |
|
|
|
|
|
console.error('Skipping because node compiled without OpenSSL CLI.'); |
|
|
process.exit(0); |
|
|
process.exit(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var common = require('../common'); |
|
|
|
|
|
var assert = require('assert'); |
|
|
var assert = require('assert'); |
|
|
var join = require('path').join; |
|
|
var join = require('path').join; |
|
|
|
|
|
|
|
|
var fs = require('fs'); |
|
|
var fs = require('fs'); |
|
|
var exec = require('child_process').exec; |
|
|
var spawn = require('child_process').spawn; |
|
|
|
|
|
|
|
|
var https = require('https'); |
|
|
var https = require('https'); |
|
|
|
|
|
|
|
@ -40,6 +41,7 @@ var options = { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var reqCount = 0; |
|
|
var reqCount = 0; |
|
|
|
|
|
var CRLF = '\r\n'; |
|
|
var body = 'hello world\n'; |
|
|
var body = 'hello world\n'; |
|
|
var cert; |
|
|
var cert; |
|
|
var subjectaltname; |
|
|
var subjectaltname; |
|
@ -62,17 +64,26 @@ var server = https.createServer(options, function(req, res) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server.listen(common.PORT, function() { |
|
|
server.listen(common.PORT, function() { |
|
|
var cmd = 'curl --insecure https://127.0.0.1:' + common.PORT + '/'; |
|
|
var args = ['s_client', |
|
|
cmd += ' --cert ' + join(common.fixturesDir, 'foafssl.crt'); |
|
|
'-quiet', |
|
|
cmd += ' --key ' + join(common.fixturesDir, 'foafssl.key'); |
|
|
'-connect', '127.0.0.1:' + common.PORT, |
|
|
console.error('executing %j', cmd); |
|
|
'-cert', join(common.fixturesDir, 'foafssl.crt'), |
|
|
exec(cmd, function(err, stdout, stderr) { |
|
|
'-key', join(common.fixturesDir, 'foafssl.key')]; |
|
|
if (err) throw err; |
|
|
|
|
|
common.error(common.inspect(stdout)); |
|
|
var client = spawn(common.opensslCli, args); |
|
|
assert.equal(body, stdout); |
|
|
|
|
|
|
|
|
client.stdout.on('data', function(data) { |
|
|
|
|
|
var message = data.toString(); |
|
|
|
|
|
var contents = message.split(CRLF + CRLF).pop(); |
|
|
|
|
|
assert.equal(body, contents); |
|
|
server.close(); |
|
|
server.close(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
client.stdin.write('GET /\n\n'); |
|
|
|
|
|
|
|
|
|
|
|
client.on('error', function(error) { |
|
|
|
|
|
throw error; |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
process.on('exit', function() { |
|
|
process.on('exit', function() { |
|
|