Permalink
Browse files

Tries to fix issue #17 - TLS on node.js >= 0.4.8

  • Loading branch information...
1 parent 96fc221 commit fbab954c6455d19fe0b7163b4d84654e0304726a @dhruvbird committed Jun 29, 2011
Showing with 18 additions and 8 deletions.
  1. +1 −0 package.json
  2. +17 −8 src/starttls.js
View
@@ -12,6 +12,7 @@
,"underscore": ">= 1.1.5"
,"eventpipe": "= 0.0.3"
,"dns-srv": ">= 0.0.6"
+ ,"semver": ">= 1.0.8"
}
,"repositories": [{"type": "svn"
,"path": "http://node-xmpp-bosh.googlecode.com/svn/trunk/"
View
@@ -13,6 +13,9 @@
// });
//
//
+
+var semver = require('semver');
+
module.exports = function starttls(socket, options, cb) {
var sslcontext = require('crypto').createCredentials(options);
@@ -22,16 +25,22 @@ module.exports = function starttls(socket, options, cb) {
var cleartext = pipe(pair, socket);
pair.on('secure', function() {
- var verifyError = pair._ssl.verifyError();
+ var verifyError;
+ if (semver.lt(semver.clean(process.version), '0.4.8')) {
+ verifyError = pair._ssl.verifyError();
+ }
+ else {
+ verifyError = pair.ssl.verifyError();
+ }
- if (verifyError) {
- cleartext.authorized = false;
- cleartext.authorizationError = verifyError;
- } else {
- cleartext.authorized = true;
- }
+ if (verifyError) {
+ cleartext.authorized = false;
+ cleartext.authorizationError = verifyError;
+ } else {
+ cleartext.authorized = true;
+ }
- if (cb) cb();
+ if (cb) cb();
});
cleartext._controlReleased = true;

0 comments on commit fbab954

Please sign in to comment.