From 10e53b7562e25b17eb3bfc01d91a2027688e5f25 Mon Sep 17 00:00:00 2001 From: Stefan Thomas Date: Thu, 6 Dec 2012 14:10:26 -0800 Subject: [PATCH] Add WebSocket Secure (SSL) support to client library. --- src/js/remote.js | 4 +++- test/config-example.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/js/remote.js b/src/js/remote.js index 793d07610c..3f5be45110 100644 --- a/src/js/remote.js +++ b/src/js/remote.js @@ -191,6 +191,7 @@ var Remote = function (opts, trace) { this.trusted = opts.trusted; this.websocket_ip = opts.websocket_ip; this.websocket_port = opts.websocket_port; + this.websocket_ssl = opts.websocket_ssl; this.local_sequence = opts.local_sequence; // Locally track sequence numbers this.local_fee = opts.local_fee; // Locally set fees this.id = 0; @@ -384,7 +385,8 @@ Remote.prototype._connect_start = function () { // with self-signed certs as the user must have pre-approved the self-signed certs. var self = this; - var url = "ws://" + this.websocket_ip + ":" + this.websocket_port; + var url = (this.websocket_ssl ? "wss://" : "ws://") + + this.websocket_ip + ":" + this.websocket_port; if (this.trace) console.log("remote: connect: %s", url); diff --git a/test/config-example.js b/test/config-example.js index af94850fe1..c43f4d5d87 100644 --- a/test/config-example.js +++ b/test/config-example.js @@ -23,6 +23,7 @@ exports.servers = { 'rpc_port' : 5005, 'websocket_ip' : "127.0.0.1", 'websocket_port' : 5006, + 'websocket_ssl' : false, 'local_sequence' : true, 'local_fee' : true, // 'validation_seed' : "shhDFVsmS2GSu5vUyZSPXYfj1r79h",