traviswingo
traviswingo

Reputation: 315

How do you connect to an EPP server (domain registry) in Node JS?

I'm building a project to manage my own domain names (just for learning purposes). The standard for interfacing with the registry API is to use their EPP server on port 700 with your username, password, and an SSL cert on the client side.

How do I connect to this in node js? Should I open a TLS connection? Their documentation is vague, at best, so if anyone has had any experience doing this, that would help out.

It's also hard testing because I'm not sure if my ip was properly whitelisted. Would like to see a sample code snippet connecting to an EPP server with username, password, and SSL cert, or perhaps just point me in the right direction as I'm most likely overthinking it :p.

Here's where I've started found from the only example online I can find in node.

var fs = require('fs')
var tls = require('tls')

var options = {
  cert: fs.readFileSync('cert.pem'),
  passphrase: 'passphrase',
  username: 'username', // ?
}

var stream = tls.connect(700, 'example.com', options);
  stream.setEncoding('utf8')
  stream.on('secureConnect', function() {
  console.log('client connected')
})
stream.on('data', function(data) {
  console.log(data)
})

But that doesn't do anything and won't make the connection.

Upvotes: 1

Views: 1543

Answers (1)

Bruno
Bruno

Reputation: 7221

If I understand it right RFC EPP can be connected by TCP.

I would use Node.JS API net to create client.

And by EPP documentation after connect you need send command in this format for example login.

var host = 'example.com';
var port = 700;
var command = '{{xml_command}}';

var client = new net.Socket();
client.connect(port, host, function() {
    console.log('Connected');
    client.write(command);
});

client.on('data', function(data) {
    console.log('Received: ' + data);
    client.destroy();
});

client.on('close', function() {
    console.log('Connection closed');
});

As an alternative I'd try node-epp and epp-reg.

Maybe I helped where to go next.

Upvotes: 2

Related Questions