From debf3894906e5b52f16c066e81679997538a55e2 Mon Sep 17 00:00:00 2001 From: Tony Metzidis Date: Sat, 11 Sep 2010 00:44:29 -0700 Subject: [PATCH] Catch Exceptions thrown when openssl is disabled --- .gitignore | 1 + test/disabled/tls_client.js | 7 ++++++- test/disabled/tls_server.js | 7 ++++++- test/simple/test-crypto.js | 7 ++++++- test/simple/test-http-tls.js | 8 +++++++- test/simple/test-net-tls.js | 9 +++++++-- 6 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 2d70f9e6c8..ba4994998c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ test/fixtures/hello.txt tmp/ node node_g +*.swp diff --git a/test/disabled/tls_client.js b/test/disabled/tls_client.js index e6ac70cc0e..6859675f00 100644 --- a/test/disabled/tls_client.js +++ b/test/disabled/tls_client.js @@ -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 () { diff --git a/test/disabled/tls_server.js b/test/disabled/tls_server.js index 239129f544..9a3f6f8199 100644 --- a/test/disabled/tls_server.js +++ b/test/disabled/tls_server.js @@ -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); diff --git a/test/simple/test-crypto.js b/test/simple/test-crypto.js index d95a6c0e30..99f855f187 100644 --- a/test/simple/test-crypto.js +++ b/test/simple/test-crypto.js @@ -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"); diff --git a/test/simple/test-http-tls.js b/test/simple/test-http-tls.js index 9f03d33fa6..d5d3b44404 100644 --- a/test/simple/test-http-tls.js +++ b/test/simple/test-http-tls.js @@ -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; diff --git a/test/simple/test-net-tls.js b/test/simple/test-net-tls.js index 5d56bea173..c10645157a 100644 --- a/test/simple/test-net-tls.js +++ b/test/simple/test-net-tls.js @@ -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 = ''; @@ -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"); -}); \ No newline at end of file +});