Created
September 15, 2011 19:27
-
-
Save dannycoates/1220229 to your computer and use it in GitHub Desktop.
ssl test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), // intentionally using http to connect to https | |
options = { | |
host: 'localhost', | |
port: 4443, | |
path: '/ping', | |
}; | |
function pingLoop() { | |
http.get(options, function (res) { | |
console.assert(false, "server should never accept http over https"); | |
}).on('error', function (e) { | |
process.nextTick(pingLoop); // blast it | |
}); | |
} | |
pingLoop(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('https'), | |
options = { | |
host: 'localhost', | |
port: 4443, | |
path: '/ping', | |
}; | |
function pingLoop() { | |
http.get(options, function (res) { | |
console.log('got statusCode: ' + res.statusCode); | |
setTimeout(pingLoop, 10); | |
}).on('error', function (e) { | |
console.log('got error: ' + e.message); | |
setTimeout(pingLoop, 10); | |
}); | |
} | |
pingLoop(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require('https'), | |
fs = require('fs'); | |
https.createServer({ | |
key: fs.readFileSync('key.pem'), // use real key here | |
cert: fs.readFileSync('cert.pem') // use real cert here | |
}, | |
function (req, res) { | |
res.end('pong\n'); | |
} | |
).listen(4443); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In node versions under 0.4.12 an ssl error from one connection can spill over into another when the ssl error list contains more than one entry.
To reproduce, run these scripts concurrently. You will notice that
correct.js
will hang at some point and stop printing output.