1

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.

traviswingo
  • 315
  • 2
  • 17
  • Can you show us some code? – Bruno Feb 08 '17 at 16:56
  • Added. Its nothing really because I'm not sure where to start. – traviswingo Feb 08 '17 at 17:12
  • Helped my answer to you somehow? – Bruno Feb 10 '17 at 08:25
  • The code to connect to the EPP server looks correct (to me), but I haven't been able to make a successful connection yet due to (what I think) invalid certificate issues. I'm still unable to resolve them and currently working with the registry. – traviswingo Feb 12 '17 at 22:41
  • Try connecting with `openssl s_client` and your certificate. As soon as you get the EPP greeting back that way it means that your IP is correctly whitelisted and then your certificate is correctly recognised by the server. After that you can try to do the same from your program. – Patrick Mevzek May 11 '17 at 19:06

1 Answers1

2

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.

Community
  • 1
  • 1
Bruno
  • 6,623
  • 5
  • 41
  • 47
  • No, this does not implement EPP correctly. See RFC5734 section 4, each EPP frame must be following its size encoded in 4 bytes. Also per its section 3, the server speaks first with a greeting message. – Patrick Mevzek Jun 05 '18 at 03:10
  • OK thx @PatrickMevzek - "hello message" make sense - Q can you offer solution how should it looks like? – Bruno Jun 05 '18 at 19:57
  • 1
    While I know a lot about EPP, I know nothing about NodeJS. So I can only say you need to follow this path: 1) establish the TLS connection properly (deal with certificate issues, etc.) 2) open the socket 3) read the server message (read the first 4 bytes - but remember that they can come in fragmented packets, then read an amount of data equal to the size encoded in these 4 bytes), that will be a greeting 4), reply with a login (again encoding size as first 4 bytes) 5) read server reply if any, check result code and go back to 3) – Patrick Mevzek Jun 05 '18 at 20:05