THRIFT-2369 Add ssl support for nodejs implementation
Patch: Pierre Lamot
diff --git a/lib/nodejs/test/multiplex_server.js b/lib/nodejs/test/multiplex_server.js
index a2a1709..a2ea535 100644
--- a/lib/nodejs/test/multiplex_server.js
+++ b/lib/nodejs/test/multiplex_server.js
@@ -25,11 +25,15 @@
SecondService = require('./gen-nodejs/SecondService'),
ttypes = require('./gen-nodejs/ThriftTest_types');
+var fs = require("fs");
+var path = require("path");
+
var program = require('commander');
program
.option('-p, --protocol <protocol>', 'Set thift protocol (binary|json) [protocol]')
.option('-t, --transport <transport>', 'Set thift transport (buffered|framed) [transport]')
+ .option('--ssl', 'use ssl transport')
.parse(process.argv);
var protocol = undefined;
@@ -72,9 +76,19 @@
"SecondService",
new SecondService.Processor(SecondServiceHandler));
-var server = thrift.createMultiplexServer(processor, {
- protocol: protocol,
- transport: transport
-});
+var options = {
+ transport: transport,
+ protocol: protocol
+};
+
+var server = undefined;
+if (program.ssl) {
+ //ssl options
+ options.key = fs.readFileSync(path.resolve(__dirname, 'server.key'));
+ options.cert = fs.readFileSync(path.resolve(__dirname, 'server.crt'));
+ server = thrift.createMultiplexSSLServer(processor, options);
+} else {
+ server = thrift.createMultiplexServer(processor, options);
+}
server.listen(9090);