Hi,


Apologies in advance, but I posted about this on Stackoverflow, but I have 
tried many things and nothing seems to work for my problem, so I am posting 
here, hoping that someone can help.


I have been trying to implement handling errors in our Node.JS app when 
there is an error when we do https.createServer().  In particular, we want 
to handle an error when the password for the .pfx file is not correct.  


I found this thread:


Node.js http.createServer how to get error 
<http://stackoverflow.com/questions/12496491/node-js-http-createserver-how-to-get-error>


but I cannot seem to make it work :(...


Here is my code:


var fs = require('fs');var https = require('https');// Setup HTTPSvar options = 
{
  pfx: fs.readFileSync('../security/server.pfx'),
  passphrase: XXXXX};
console.log("++++++++ Listen SSL Mode ++++++++");var secureServer = 
https.createServer(options, app);
secureServer.on('error', function (e) {
    // Handle your error here
    console.log(e);
    });
secureServer.listen(LISTENPORT);


When I try that, it's like the "secureServer.on()' is not being processed 
at all:


++++++++ Listen SSL Mode ++++++++
_tls_common.js:137
      c.context.loadPKCS12(pfx, passphrase);
                ^
Error: mac verify failure
    at Error (native)
    at Object.createSecureContext (_tls_common.js:137:17)
    at Server (_tls_wrap.js:768:25)
    at new Server (https.js:26:14)
    at Object.exports.createServer (https.js:47:10)



We know that (we have tried this) using process.on() to catch an 
uncaughtexception seems to work, but we would like to catch (and handle) 
this particular situation (bad/incorrect password) more specifically.


Can someone tell me what I might be doing wrong?


I have also tried using the ".on('error',...)" on the ".listen()" but that 
doesn't do anything.


Thanks, Jim

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/a7926a80-8cb4-4a9a-9209-c4e995f539b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to