Created
September 2, 2013 21:30
-
-
Save marlun/6417445 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tls = require('tls') | |
var fs = require('fs') | |
var parser = require('xml2json') | |
var options = { | |
host: 'epp.example.com', | |
key: fs.readFileSync('key.pem'), | |
cert: fs.readFileSync('cert.pem'), | |
passphrase: 'pass' | |
} | |
var stream = tls.connect(700, options, function() { | |
console.log('Client connected.', | |
stream.authorized ? 'authorized' : 'unauthorized') | |
process.stdin.pipe(stream) | |
}) | |
stream.setEncoding('utf8') | |
stream.on('readable', function() { | |
var data = stream.read() | |
if (data.length === 4) return; | |
var response = parser.toJson(data, { object: true }) | |
console.log(response) | |
}) | |
stream.on('end', function() { | |
console.log('Stream closed.') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment