Permalink
Browse files

Merge pull request #78 from nordstrom-innovation/master

Added support for client-side SSL
  • Loading branch information...
2 parents 85d3442 + d8f4718 commit 8dd03b051af4f7b4cdeaa11057aa17577a36a128 @milewise milewise committed Sep 1, 2012
Showing with 35 additions and 18 deletions.
  1. +16 −17 lib/http.js
  2. +19 −1 lib/soap.js
View
@@ -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]; }
@@ -51,4 +51,3 @@ exports.request = function(rurl, data, callback, exheaders, exoptions) {
request.on('error', callback);
request.end(data);
}
-
View
@@ -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 = {};
@@ -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;
@@ -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;

0 comments on commit 8dd03b0

Please sign in to comment.