This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Catch Exceptions thrown when openssl is disabled

  • Loading branch information...
1 parent 5c9b9c2 commit debf3894906e5b52f16c066e81679997538a55e2 @tonymet tonymet committed with ry Sep 11, 2010
View
@@ -12,3 +12,4 @@ test/fixtures/hello.txt
tmp/
node
node_g
+*.swp
@@ -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 () {
@@ -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);
@@ -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");
@@ -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;
@@ -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");
-});
+});

0 comments on commit debf389

Please sign in to comment.