Skip to content

Commit

Permalink
Merge pull request vpulim#78 from nordstrom-innovation/master
Browse files Browse the repository at this point in the history
Added support for client-side SSL
  • Loading branch information
milewise committed Sep 1, 2012
2 parents 85d3442 + d8f4718 commit 8dd03b0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
33 changes: 16 additions & 17 deletions lib/http.js
Expand Up @@ -10,34 +10,34 @@ var VERSION = "0.2.0";

exports.request = function(rurl, data, callback, exheaders, exoptions) {
var curl = url.parse(rurl);
var secure = curl.protocol == 'https:';
var host = curl.hostname;
var port = parseInt(curl.port || (secure ? 443 : 80));
var path = [curl.pathname || '/', curl.search || '', curl.hash || ''].join('');
var method = data ? "POST" : "GET";
var headers = {
"User-Agent": "node-soap/" + VERSION,
"Accept" : "text/html,application/xhtml+xml,application/xml",
var secure = curl.protocol == 'https:';
var host = curl.hostname;
var port = parseInt(curl.port || (secure ? 443 : 80));
var path = [curl.pathname || '/', curl.search || '', curl.hash || ''].join('');
var method = data ? "POST" : "GET";
var headers = {
"User-Agent": "node-soap/" + VERSION,
"Accept" : "text/html,application/xhtml+xml,application/xml",
"Accept-Encoding": "none",
"Accept-Charset": "utf-8",
"Connection": "close",
"Host" : host
};
"Host" : host
};

if (typeof data == 'string') {
headers["Content-Length"] = Buffer.byteLength(data, 'utf8');;
headers["Content-Type"] = "application/x-www-form-urlencoded";
}
if (typeof data == 'string') {
headers["Content-Length"] = Buffer.byteLength(data, 'utf8');;
headers["Content-Type"] = "application/x-www-form-urlencoded";
}

exheaders = exheaders || {};
for (var attr in exheaders) { headers[attr] = exheaders[attr]; }
for (var attr in exheaders) { headers[attr] = exheaders[attr]; }

var options = {
uri: curl,
method: method,
headers: headers
};

exoptions = exoptions || {};
for (var attr in exoptions) { options[attr] = exoptions[attr]; }

Expand All @@ -51,4 +51,3 @@ exports.request = function(rurl, data, callback, exheaders, exoptions) {
request.on('error', callback);
request.end(data);
}

20 changes: 19 additions & 1 deletion lib/soap.js
Expand Up @@ -7,7 +7,9 @@ var Client = require('./client').Client,
Server = require('./server').Server,
open_wsdl = require('./wsdl').open_wsdl,
crypto = require('crypto'),
WSDL = require('./wsdl').WSDL;
WSDL = require('./wsdl').WSDL,
https = require('https'),
fs = require('fs');

var WSDL = require('./wsdl').WSDL;
var _wsdlCache = {};
Expand Down Expand Up @@ -73,6 +75,21 @@ BasicAuthSecurity.prototype.toXML = function() {
return "";
}

function ClientSSLSecurity(keyPath, certPath) {
this.key = fs.readFileSync(keyPath);
this.cert = fs.readFileSync(certPath);
}

ClientSSLSecurity.prototype.toXML = function (headers) {
return "";
}

ClientSSLSecurity.prototype.addOptions = function (options) {
options.key = this.key;
options.cert = this.cert;
options.agent = new https.Agent(options);
}

function WSSecurity(username, password, passwordType) {
this._username = username;
this._password = password;
Expand Down Expand Up @@ -128,6 +145,7 @@ WSSecurity.prototype.toXML = function() {

exports.BasicAuthSecurity = BasicAuthSecurity;
exports.WSSecurity = WSSecurity;
exports.ClientSSLSecurity = ClientSSLSecurity;
exports.createClient = createClient;
exports.passwordDigest = passwordDigest;
exports.listen = listen;
Expand Down

0 comments on commit 8dd03b0

Please sign in to comment.