mardi 31 mars 2015

HTTPS using a .pfx file


var https = require('https');
var fs = require('fs');
var atob = require('atob');

var options = {
pfx: atob(fs.readFileSync('server.pfx').toString())
};

https.createServer(options, function(req, res) {
res.writeHead(200);
res.end("Hello world!\n");
}).listen(1337);


I'm pretty sure I didn't screw up the certificate or anything (tho I'm a newb at SSL)… I copied the code pretty much from the HTTPS module official docs. I got this:



crypto.js:176
c.context.loadPKCS12(pfx);
^
Error: wrong tag
at Object.exports.createCredentials (crypto.js:176:17)
at Server (tls.js:1127:28)
at new Server (https.js:35:14)
at Object.exports.createServer (https.js:54:10)
at Object.<anonymous> (/Users/brian/Desktop/DevDoodle/https.js:9:7)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)


I assume the problem has to do with crypto.createCredentials, which is deprecated. ಠ_ಠ


Am I using the HTTPS module correctly? What can I do to make SSL work?


Aucun commentaire:

Enregistrer un commentaire