None
Net::EPP::Simple - a simple \s-1EPP\s0 client interface for the most common jobs
#!/usr/bin/perl use Net::EPP::Simple; use strict; my $epp = Net::EPP::Simple->new( host => 'epp.nic.tld', user => 'my-id', pass => 'my-password', ); my $domain = 'example.tld'; if ($epp->check_domain($domain) == 1) { print "Domain is available\n" ; } else { my $info = $epp->domain_info($domain); printf("Domain was registered on %s by %s\n", $info->{crDate}, $info->{crID}); }
\s-1EPP\s0 is the Extensible Provisioning Protocol. \s-1EPP\s0 (defined in \s-1RFC\s0 4930) is an application layer client-server protocol for the provisioning and management of objects stored in a shared central repository. Specified in \s-1XML\s0, the protocol defines generic object management operations and an extensible framework that maps protocol operations to objects. As of writing, its only well-developed application is the provisioning of Internet domain names, hosts, and related contact details.
This module provides a high level interface to the \s-1EPP\s0 protocol. It hides all the boilerplate of connecting, logging in, building request frames and parsing response frames behind a simple, Perlish interface.
It is based on the \*(C`Net::EPP::Client\*(C' module and uses \*(C`Net::EPP::Frame\*(C' to build request frames.
The constructor for \*(C`Net::EPP::Simple\*(C' has the same general form as the one for \*(C`Net::EPP::Client\*(C', but with the following exceptions:
Unless otherwise set, \*(C`port\*(C' defaults to 700
Unless the \*(C`no_ssl\*(C' parameter is set, \s-1SSL\s0 is always on
You can use the \*(C`user\*(C' and \*(C`pass\*(C' parameters to supply authentication information.
The \*(C`timeout\*(C' parameter controls how long the client waits for a response from the server before returning an error.
if \*(C`debug\*(C' is set, \*(C`Net::EPP::Simple\*(C' will output verbose debugging information on \*(C`STDERR\*(C', including all frames sent to and received from the server.
\*(C`reconnect\*(C' can be used to disable automatic reconnection (it is enabled by default). Before sending a frame to the server, \*(C`Net::EPP::Simple\*(C' will send a \*(C`<hello>\*(C' to check that the connection is up, if not, it will try to reconnect, aborting after the nth time, where n is the value of \*(C`reconnect\*(C' (the default is 3).
\*(C`login\*(C' can be used to disable automatic logins. If you set it to 0, you can manually log in using the \*(C`$epp-\*(C'_login()> method.
The constructor will establish a connection to the server and retrieve the greeting (which is available via $epp->{greeting}) and then send a <login> request.
If the login fails, the constructor will return \*(C`undef\*(C' and set $Net::EPP::Simple::Error and $Net::EPP::Simple::Code.
\s-1RFC\s0 5730 requires that all \s-1EPP\s0 instances must be protected using \*(L"mutual, strong client-server authentication\*(R". In practice, this means that both client and server must present an \s-1SSL\s0 certificate, and that they must both verify the certificate of their peer.
Server Certificate Verification
\*(C`Net::EPP::Simple\*(C' will verify the certificate presented by a server if the \*(C`verify\*(C', and either \*(C`ca_file\*(C' or \*(C`ca_path\*(C' are passed to the constructor:
my $epp = Net::EPP::Simple->new( host => 'epp.nic.tld', user => 'my-id', pass => 'my-password', verify => 1, ca_file => '/etc/pki/tls/certs/ca-bundle.crt', ca_path => '/etc/pki/tls/certs', );
\*(C`Net::EPP::Simple\*(C' will fail to connect to the server if the certificate is not valid.
\s-1SSL\s0 Cipher Selection
You can restrict the ciphers that you will use to connect to the server by passing a \*(C`ciphers\*(C' parameter to the constructor. This is a colon- separated list of cipher names and aliases. See <http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS> for further details. As an example, the following cipher list is suggested for clients who wish to ensure high-security connections to servers:
HIGH:!ADH:!MEDIUM:!LOW:!SSLv2:!EXP
Client Certificates
If you are connecting to an \s-1EPP\s0 server which requires a client certificate, you can configure \*(C`Net::EPP::Simple\*(C' to use one as follows:
my $epp = Net::EPP::Simple->new( host => 'epp.nic.tld', user => 'my-id', pass => 'my-password', key => '/path/to/my.key', cert => '/path/to/my.crt', passphrase => 'foobar123', );
\*(C`key\*(C' is the filename of the private key, \*(C`cert\*(C' is the filename of the certificate. If the private key is encrypted, the \*(C`passphrase\*(C' parameter will be used to decrypt it.
\*(C`Net::EPP::Simple\*(C' supports the use of a simple configuration file. To use this feature, you need to install the Config::Simple module.
When starting up, \*(C`Net::EPP::Simple\*(C' will look for \*(C`$HOME/.net-epp-simple-rc\*(C'. This file is an ini-style configuration file.
Default Options
You can specify default options for all \s-1EPP\s0 servers using the \*(C`[default]\*(C' section:
[default] default=epp.nic.tld debug=1
Server Specific Options
You can specify options for for specific \s-1EPP\s0 servers by giving each \s-1EPP\s0 server its own section:
[epp.nic.tld] user=abc123 pass=foo2bar port=777 ssl=0
This means that when you write a script that uses \*(C`Net::EPP::Simple\*(C', you can do the following:
# config file has a default server: my $epp = Net::EPP::Simple->new;
# config file has connection options for this EPP server: my $epp = Net::EPP:Simple->new('host' => 'epp.nic.tld');
Any parameters provided to the constructor will override those in the config file.
You can do a simple \*(C`<check>\*(C' request for an object like so:
my $result = $epp->check_domain($domain);
my $result = $epp->check_host($host);
my $result = $epp->check_contact($contact);
Each of these methods has the same profile. They will return one of the following:
\*(C`undef\*(C' in the case of an error (check $Net::EPP::Simple::Error and $Net::EPP::Simple::Code).
0 if the object is already provisioned.
1 if the object is available.
You can retrieve information about an object by using one of the following:
my $info = $epp->domain_info($domain, $authInfo, $follow);
my $info = $epp->host_info($host);
my $info = $epp->contact_info($contact, $authInfo);
\*(C`Net::EPP::Simple\*(C' will construct an \*(C`<info>\*(C' frame and send it to the server, then parse the response into a simple hash ref. The layout of the hash ref depends on the object in question. If there is an error, these methods will return \*(C`undef\*(C', and you can then check $Net::EPP::Simple::Error and $Net::EPP::Simple::Code.
If $authInfo is defined, it will be sent to the server as per \s-1RFC\s0 5731, Section 3.1.2 and \s-1RFC\s0 5733, Section 3.1.2. If the supplied authInfo code is validated by the registry, additional information will appear in the response. If it is invalid, you should get an error.
If the $follow parameter is true, then \*(C`Net::EPP::Simple\*(C' will also retrieve the relevant host and contact details for a domain: instead of returning an object name or \s-1ID\s0 for the domain's registrant, contact associations, \s-1DNS\s0 servers or subordinate hosts, the values will be replaced with the return value from the appropriate \*(C`host_info()\*(C' or \*(C`contact_info()\*(C' command (unless there was an error, in which case the original object \s-1ID\s0 will be used instead).
The hash ref returned by \*(C`domain_info()\*(C' will usually look something like this:
$info = { 'contacts' => { 'admin' => 'contact-id' 'tech' => 'contact-id' 'billing' => 'contact-id' }, 'registrant' => 'contact-id', 'clID' => 'registrar-id', 'roid' => 'tld-12345', 'status' => [ 'ok' ], 'authInfo' => 'abc-12345', 'name' => 'example.tld', 'trDate' => '2011-01-18T11:08:03.0Z', 'ns' => [ 'ns0.example.com', 'ns1.example.com', ], 'crDate' => '2011-02-16T12:06:31.0Z', 'exDate' => '2011-02-16T12:06:31.0Z', 'crID' => 'registrar-id', 'upDate' => '2011-08-29T04:02:12.0Z', hosts => [ 'ns0.example.tld', 'ns1.example.tld', ], };
Members of the \*(C`contacts\*(C' hash ref may be strings or, if there are multiple associations of the same type, an anonymous array of strings. If the server uses the \*(L"hostAttr\*(R" model instead of \*(L"hostObj\*(R", then the \*(C`ns\*(C' member will look like this:
$info->{ns} = [ { name => 'ns0.example.com', addrs => [ type => 'v4', addr => '10.0.0.1', ], }, { name => 'ns1.example.com', addrs => [ type => 'v4', addr => '10.0.0.2', ], }, ];
Note that there may be multiple members in the \*(C`addrs\*(C' section and that the \*(C`type\*(C' attribute is optional.
The hash ref returned by \*(C`host_info()\*(C' will usually look something like this:
$info = { 'crDate' => '2011-09-17T15:38:56.0Z', 'clID' => 'registrar-id', 'crID' => 'registrar-id', 'roid' => 'tld-12345', 'status' => [ 'linked', 'serverDeleteProhibited', ], 'name' => 'ns0.example.tld', 'addrs' => [ { 'version' => 'v4', 'addr' => '10.0.0.1' } ] };
Note that hosts may have multiple addresses, and that \*(C`version\*(C' is optional.
The hash ref returned by \*(C`contact_info()\*(C' will usually look something like this:
$VAR1 = { 'id' => 'contact-id', 'postalInfo' => { 'int' => { 'name' => 'John Doe', 'org' => 'Example Inc.', 'addr' => { 'street' => [ '123 Example Dr.' 'Suite 100' ], 'city' => 'Dulles', 'sp' => 'VA', 'pc' => '20116-6503' 'cc' => 'US', } } }, 'clID' => 'registrar-id', 'roid' => 'CNIC-HA321983', 'status' => [ 'linked', 'serverDeleteProhibited' ], 'voice' => '+1.7035555555x1234', 'fax' => '+1.7035555556', 'email' => '[email protected]', 'crDate' => '2011-09-23T03:51:29.0Z', 'upDate' => '1999-11-30T00:00:00.0Z' };
There may be up to two members of the \*(C`postalInfo\*(C' hash, corresponding to the \*(C`int\*(C' and \*(C`loc\*(C' internationalised and localised types.
The \s-1EPP\s0 \*(C`<transfer>\*(C' command suppots five different operations: query, request, cancel, approve, and reject. \*(C`Net::EPP::Simple\*(C' makes these available using the following methods:
# For domain objects:
$epp->domain_transfer_query($domain); $epp->domain_transfer_cancel($domain); $epp->domain_transfer_request($domain, $authInfo, $period); $epp->domain_transfer_approve($domain); $epp->domain_transfer_reject($domain);
# For contact objects:
$epp->contact_transfer_query($contact); $epp->contact_transfer_cancel($contact); $epp->contact_transfer_request($contact, $authInfo); $epp->contact_transfer_approve($contact); $epp->contact_transfer_reject($contact);
Most of these methods will just set the value of $Net::EPP::Simple::Code and return either true or false. However, the \*(C`domain_transfer_request()\*(C', \*(C`domain_transfer_query()\*(C', \*(C`contact_transfer_request()\*(C' and \*(C`contact_transfer_query()\*(C' methods will return a hash ref that looks like this:
my $trnData = { 'name' => 'example.tld', 'reID' => 'losing-registrar', 'acDate' => '2011-12-04T12:24:53.0Z', 'acID' => 'gaining-registrar', 'reDate' => '2011-11-29T12:24:53.0Z', 'trStatus' => 'pending' };
The following methods can be used to create a new object at the server:
$epp->create_domain($domain); $epp->create_host($host); $epp->create_contact($contact);
The argument for these methods is a hash ref of the same format as that returned by the info methods above. As a result, cloning an existing object is as simple as the following:
my $info = $epp->contact_info($contact);
# set a new contact ID to avoid clashing with the existing object $info->{id} = $new_contact;
# randomize authInfo: $info->{authInfo} = $random_string;
$epp->create_contact($info);
\*(C`Net::EPP::Simple\*(C' will ignore object properties that it does not recognise, and those properties (such as server-managed status codes) that clients are not permitted to set.
When creating a new domain object, you may also specify a \*(C`period\*(C' key, like so:
my $domain = { 'name' => 'example.tld', 'period' => 2, 'registrant' => 'contact-id', 'contacts' => { 'tech' => 'contact-id', 'admin' => 'contact-id', 'billing' => 'contact-id', }, 'status' => [ 'clientTransferProhibited', ], 'ns' => { 'ns0.example.com', 'ns1.example.com', }, };
$epp->create_domain($domain);
The \*(C`period\*(C' key is assumed to be in years rather than months. \*(C`Net::EPP::Simple\*(C' assumes the registry uses the host object model rather than the host attribute model.
my $host = { name => 'ns1.example.tld', addrs => [ { ip => '123.45.67.89', version => 'v4' }, { ip => '98.76.54.32', version => 'v4' }, ], }; $epp->create_host($host);
The following methods can be used to update an object at the server:
$epp->update_domain($domain); $epp->update_host($host); $epp->update_contact($contact);
Each of these methods has the same profile. They will return one of the following:
undef in the case of an error (check $Net::EPP::Simple::Error and $Net::EPP::Simple::Code).
1 if the update request was accepted.
You may wish to check the value of $Net::EPP::Simple::Code to determine whether the response code was 1000 (\s-1OK\s0) or 1001 (action pending).
Use update_domain() method to update domains' data.
The update info parameter may look like: $update_info = {
name => $domain, chg => { registrant => $new_registrant_id, authInfo => $new_domain_password, }, add => { # \s-1DNS\s0 info with \*(L"hostObj\*(R" or \*(L"hostAttr\*(R" model, see create_domain() ns => [ ns1.example.com ns2.example.com ], contacts => { tech => 'contact-id', billing => 'contact-id', admin => 'contact-id', },
# Status info, simple form: status => [ qw/ clientUpdateProhibited clientHold / ],
# Status info may be in more detailed form: # status => { # clientUpdateProbhibited => 'Avoid accidental change', # clientHold => 'This domain is not delegated', # }, }, rem => { ns => [ ... ], contacts => { tech => 'old_tech_id', billing => 'old_billing_id', admin => 'old_admin_id', }, status => [ qw/ clientTransferProhibited ... / ], }, }
All fields except 'name' in $update_info hash are optional.
Use update_contact() method to update contact's data.
The $update_info for contacts may look like this:
$update_info = {
id => $contact_id, add => { status => [ qw/ clientDeleteProhibited / ], # \s-1OR\s0 # status => { # clientDeleteProhibited => 'Avoid accidental removal', # }, }, rem => { status => [ qw/ clientUpdateProhibited / ], }, chg => { postalInfo => { int => { name => 'John Doe', org => 'Example Inc.', addr => { street => [ '123 Example Dr.' 'Suite 100' ], city => 'Dulles', sp => '\s-1VA\s0', pc => '20116-6503' cc => '\s-1US\s0', }, }, }, voice => '+1.7035555555x1234', fax => '+1.7035555556', email => '[email protected]', authInfo => 'new-contact-password', },
}
All fields except 'id' in $update_info hash are optional.
Use update_host() method to update \s-1EPP\s0 hosts.
The $update_info for hosts may look like this:
$update_info = {
name => 'ns1.example.com', add => { status => [ qw/ clientDeleteProhibited / ], # \s-1OR\s0 # status => { # clientDeleteProhibited => 'Avoid accidental removal', # },
addrs => [ { ip => '123.45.67.89', version => 'v4' }, { ip => '98.76.54.32', version => 'v4' }, ], }, rem => { status => [ qw/ clientUpdateProhibited / ], addrs => [ { ip => '1.2.3.4', version => 'v4' }, { ip => '5.6.7.8', version => 'v4' }, ], }, chg => { name => 'ns2.example.com', }, }
All fields except first 'name' in $update_info hash are optional.
The following methods can be used to delete an object at the server:
$epp->delete_domain($domain); $epp->delete_host($host); $epp->delete_contact($contact);
Each of these methods has the same profile. They will return one of the following:
undef in the case of an error (check $Net::EPP::Simple::Error and $Net::EPP::Simple::Code).
1 if the deletion request was accepted.
You may wish to check the value of $Net::EPP::Simple::Code to determine whether the response code was 1000 (\s-1OK\s0) or 1001 (action pending).
You can extend the validity period of the domain object by issuing a renew_domain() command.
my $result = $epp->renew_domain({ name => 'example.com', cur_exp_date => '2011-02-05', # current expiration date period => 2, # prolongation period in years });
Return value is 1 on success and \*(C`undef\*(C' on error. In the case of error $Net::EPP::Simple::Error contains the appropriate error message.
my $greeting = $epp->greeting;
Returns the a \*(C`Net::EPP::Frame::Greeting\*(C' object representing the greeting returned by the server.
$epp->ping;
Checks that the connection is up by sending a \*(C`<hello>\*(C' to the server. Returns false if no response is received. \*(C`Net::EPP::Simple\*(C' overrides some methods inherited from \*(C`Net::EPP::Client\*(C'. These are described below: \*(C`Net::EPP::Simple\*(C' overrides this method so it can automatically populate the \*(C`<clTRID>\*(C' element with a unique string. It then passes the frame back up to \*(C`Net::EPP::Client\*(C'. \*(C`Net::EPP::Simple\*(C' overrides this method so it can catch timeouts and network errors. If such an error occurs it will return \*(C`undef\*(C'.
This variable contains an english text message explaining the last error to occur. This is may be due to invalid parameters being passed to a method, a network error, or an error response being returned by the server. This variable contains the contains the text content of the \*(C`<msg>\*(C' element in the response frame for the last transaction. This variable contains the integer result code returned by the server for the last transaction. A successful transaction will always return an error code of 1999 or lower, for an unsuccessful transaction it will be 2011 or more. If there is an internal client error (due to invalid parameters being passed to a method, or a network error) then this will be set to 2400 (\*(C`COMMAND_FAILED\*(C'). See Net::EPP::ResponseCodes for more information about thes codes.
CentralNic Ltd (<http://www.centralnic.com/>).
This module is (c) 2012 CentralNic Ltd. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Net::EPP::Client
Net::EPP::Frame
Net::EPP::Proxy
RFCs 5730 and \s-1RFC\s0 4934, available from <http://www.ietf.org/>.
The CentralNic \s-1EPP\s0 site at <http://www.centralnic.com/registrars/epp>.