javascript - How to use tlsSocket.renegotiate(options, callback) in Node.js 0.11.8 and higher -


i'm new node.js , have simple https server running. when user requests context path server should initiate ssl renegotiation , ask client certificate authentication. saw supported in node.js 0.11.8 , higher.

i tried far, renegotiation not happening. not error thrown.

var https = require('https'); var fs = require('fs');  var optssl = {    key: fs.readfilesync('ssl/server/keys/server.key'),    cert: fs.readfilesync('ssl/server/certs/server.crt'),    ca: fs.readfilesync('ssl/ca/ca.crt'),    requestcert: false,    rejectunauthorized: true,    ciphers: 'ecdh+aesgcm:dh+aesgcm:ecdh+aes256:dh+aes256:ecdh+aes128:dh+aes:ecdh+3des:dh+3des:rsa+aesgcm:rsa+aes:rsa+3des:!anull:!md5:!dss',    honorcipherorder: true };  var optclientauth = {     requestcert: true,     rejectunauthorized: true };  var server = https.createserver(optssl, function(req, res){     res.writehead(200);     res.end("hello world\n"); });  server.on('request', function(req, res){     console.log('request emitted on ' + req.url);     if (req.url == '/secure') {         try {             var socket = req.connection;             socket.renegotiate(optclientauth, function(err){                 if (!err) {                     console.log(req.connection.getpeercertificate());                 } else {                     console.log(err.message);                 }             });         } catch (err) {             console.log(err);         }     }; });  server.on('secureconnection', function(socket) {     console.log('secure connection established'); });  server.listen(8443); 

thank support.

this code works me.

var https = require('https'); var fs = require('fs'); var constants = require('constants');  var optssl = {     key: fs.readfilesync('./server.key'),     cert: fs.readfilesync('./server.crt'),     ca: fs.readfilesync('./ca.crt'),     passphrase: "very_secret",     agent: false,     requestcert: false,     rejectunauthorized: false,     ciphers: 'ecdh+aesgcm:dh+aesgcm:ecdh+aes256:dh+aes256:ecdh+aes128:dh+aes:ecdh+3des:dh+3des:rsa+aesgcm:rsa+aes:rsa+3des:!anull:!md5:!dss',     honorcipherorder: true,     secureoptions: constants.ssl_op_no_sslv3 | constants.ssl_op_no_sslv2 };  var optclientauth = {     requestcert: true,     rejectunauthorized: true };  var server = https.createserver(optssl);  server.on('request', function(req, res){     console.log('request emitted on ' + req.url);     var socket = req.connection;     if (req.url == '/secure') {         var result = socket.renegotiate(optclientauth, function(err){             if (!err) {                 console.log(req.connection.getpeercertificate());                  res.writehead(200);                 res.end("authenticated hello world\n");             } else {                 console.log(err.message);             }         });     } else {         res.writehead(200);         res.end("secured hello world\n");     }; });  server.listen(8443); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -