Skip to content

Commit

Permalink
Catch Exceptions thrown when openssl is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
tonymet authored and ry committed Sep 13, 2010
1 parent 5c9b9c2 commit debf389
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ test/fixtures/hello.txt
tmp/
node
node_g
*.swp
7 changes: 6 additions & 1 deletion test/disabled/tls_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ var client = net.createConnection(443, "www.microsoft.com");
var caPem = fs.readFileSync(common.fixturesDir+"/msca.pem");
//var caPem = fs.readFileSync("ca.pem");

var credentials = crypto.createCredentials({ca:caPem});
try{
var credentials = crypto.createCredentials({ca:caPem});
} catch (e) {
console.log("Not compiled with OPENSSL support.");
process.exit();
}

client.setEncoding("UTF8");
client.addListener("connect", function () {
Expand Down
7 changes: 6 additions & 1 deletion test/disabled/tls_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ var crypto=require('crypto');
var keyPem = fs.readFileSync(common.fixturesDir + "/cert.pem");
var certPem = fs.readFileSync(common.fixturesDir + "/cert.pem");

var credentials = crypto.createCredentials({key:keyPem, cert:certPem});
try{
var credentials = crypto.createCredentials({key:keyPem, cert:certPem});
} catch (e) {
console.log("Not compiled with OPENSSL support.");
process.exit();
}
var i = 0;
var server = net.createServer(function (connection) {
connection.setSecure(credentials);
Expand Down
7 changes: 6 additions & 1 deletion test/simple/test-crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ var caPem = fs.readFileSync(common.fixturesDir+"/test_ca.pem", 'ascii');
var certPem = fs.readFileSync(common.fixturesDir+"/test_cert.pem", 'ascii');
var keyPem = fs.readFileSync(common.fixturesDir+"/test_key.pem", 'ascii');

var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
try{
var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
} catch (e) {
console.log("Not compiled with OPENSSL support.");
process.exit();
}

// Test HMAC
//var h1 = (new crypto.Hmac).init("sha1", "Node").update("some data").update("to hmac").digest("hex");
Expand Down
8 changes: 7 additions & 1 deletion test/simple/test-http-tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ var caPem = fs.readFileSync(common.fixturesDir+"/test_ca.pem", 'ascii');
var certPem = fs.readFileSync(common.fixturesDir+"/test_cert.pem", 'ascii');
var keyPem = fs.readFileSync(common.fixturesDir+"/test_key.pem", 'ascii');

var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
try{
var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
} catch (e) {
console.log("Not compiled with OPENSSL support.");
process.exit();
}


var https_server = http.createServer(function (req, res) {
res.id = request_number;
Expand Down
9 changes: 7 additions & 2 deletions test/simple/test-net-tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ var caPem = fs.readFileSync(common.fixturesDir+"/test_ca.pem", 'ascii');
var certPem = fs.readFileSync(common.fixturesDir+"/test_cert.pem", 'ascii');
var keyPem = fs.readFileSync(common.fixturesDir+"/test_key.pem", 'ascii');

var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
try{
var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
} catch (e) {
console.log("Not compiled with OPENSSL support.");
process.exit();
}

var testData = "TEST123";
var serverData = '';
Expand Down Expand Up @@ -96,4 +101,4 @@ secureServer.addListener("listening", function() {
process.addListener("exit", function () {
assert.ok(gotSecureServer, "Did not get secure event for server");
assert.ok(gotSecureClient, "Did not get secure event for clientr");
});
});

0 comments on commit debf389

Please sign in to comment.