简体   繁体   中英

Getting openssl stream in node.js

I have a server that's using TLS 1.0 It gives me an infinite stream of data on the terminal when the command

~$ openssl s_client -connect 'serveraddress':5000

This provides me with a realtime xml data stream of what my server is currently doing. I want to connect to it using node.js or any other way that provides me with the possibility to push this data stream as a websocket or directly onto a JS, but I can't seem to figure out how. Can any of you please help? Thanks :)

I think something like that should solve your problem.

var terminal = require('child_process').spawn('bash');

terminal.stdout.on('data', function (data) {
    console.log('stdout: ' + data);
});

terminal.on('exit', function (code) {
        console.log('child process exited with code ' + code);
});

setTimeout(function() {
    console.log('Sending stdin to terminal');
    terminal.stdin.write("openssl s_client -connect 'serveraddress':5000");
    terminal.stdin.end();
}, 1000);

Edit: Try this for a working example:

terminal.stdin.write("ping www.google.de");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM