line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## Domain Registry Interface, EPP Connection handling |
2
|
|
|
|
|
|
|
## |
3
|
|
|
|
|
|
|
## Copyright (c) 2005-2013 Patrick Mevzek . All rights reserved. |
4
|
|
|
|
|
|
|
## |
5
|
|
|
|
|
|
|
## This file is part of Net::DRI |
6
|
|
|
|
|
|
|
## |
7
|
|
|
|
|
|
|
## Net::DRI is free software; you can redistribute it and/or modify |
8
|
|
|
|
|
|
|
## it under the terms of the GNU General Public License as published by |
9
|
|
|
|
|
|
|
## the Free Software Foundation; either version 2 of the License, or |
10
|
|
|
|
|
|
|
## (at your option) any later version. |
11
|
|
|
|
|
|
|
## |
12
|
|
|
|
|
|
|
## See the LICENSE file that comes with this distribution for more details. |
13
|
|
|
|
|
|
|
#################################################################################################### |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Net::DRI::Protocol::EPP::Connection; |
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
5
|
|
4100
|
use utf8; |
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
33
|
|
18
|
5
|
|
|
5
|
|
162
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
158
|
|
19
|
5
|
|
|
5
|
|
34
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
138
|
|
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
5
|
|
591
|
use Net::DRI::Util; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
113
|
|
22
|
5
|
|
|
5
|
|
949
|
use Net::DRI::Data::Raw; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
42
|
|
23
|
5
|
|
|
5
|
|
1340
|
use Net::DRI::Protocol::ResultStatus; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
37
|
|
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
5
|
|
2893
|
use Net::SSLeay; |
|
5
|
|
|
|
|
49212
|
|
|
5
|
|
|
|
|
3041
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=pod |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Net::DRI::Protocol::EPP::Connection - EPP over TCP/TLS Connection Handling (RFC5734) for Net::DRI |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Please see the README file for details. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SUPPORT |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
For now, support questions should be sent to: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Enetdri@dotandco.comE |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Please also see the SUPPORT file in the distribution. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Ehttp://www.dotandco.com/services/software/Net-DRI/E |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Patrick Mevzek, Enetdri@dotandco.comE |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 COPYRIGHT |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Copyright (c) 2005-2013 Patrick Mevzek . |
56
|
|
|
|
|
|
|
All rights reserved. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
59
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
60
|
|
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or |
61
|
|
|
|
|
|
|
(at your option) any later version. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
See the LICENSE file that comes with this distribution for more details. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#################################################################################################### |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub read_fragments |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
|
|
0
|
0
|
|
my ($sock,$length)=@_; |
72
|
0
|
|
|
|
|
|
my $data=''; |
73
|
0
|
|
|
|
|
|
while($length > 0) |
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
|
|
|
my $new; |
76
|
0
|
|
|
|
|
|
my $read=$sock->sysread($new,$length); |
77
|
0
|
0
|
|
|
|
|
die(Net::DRI::Protocol::ResultStatus->new_error('COMMAND_SYNTAX_ERROR','Error reading socket','en')) unless $read; |
78
|
0
|
|
|
|
|
|
$length-=$read; |
79
|
0
|
|
|
|
|
|
$data.=$new; |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
return $data; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub read_data |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
0
|
0
|
|
my ($class,$to,$sock)=@_; |
87
|
0
|
|
|
|
|
|
my $header=read_fragments($sock,4); ## first 4 bytes are the packed length |
88
|
0
|
0
|
|
|
|
|
die(Net::DRI::Protocol::ResultStatus->new_error('COMMAND_SYNTAX_ERROR','Unable to read frame length','en')) unless length $header; |
89
|
0
|
|
|
|
|
|
my $length=unpack('N',$header)-4; ## Length of the XML frame |
90
|
0
|
0
|
|
|
|
|
die(Net::DRI::Protocol::ResultStatus->new_error('COMMAND_SYNTAX_ERROR','Unable to decode frame length','en')) unless $length > 0; |
91
|
0
|
|
|
|
|
|
my $frame=Net::DRI::Util::decode_utf8(read_fragments($sock,$length)); |
92
|
0
|
0
|
|
|
|
|
die(Net::DRI::Protocol::ResultStatus->new_error('COMMAND_SYNTAX_ERROR','','en')) unless length $frame; |
93
|
0
|
0
|
|
|
|
|
die(Net::DRI::Protocol::ResultStatus->new_error('COMMAND_SYNTAX_ERROR','Got unexpected EPP message: '.$frame,'en')) unless $frame=~m!\s*$!s; |
94
|
0
|
|
|
|
|
|
return Net::DRI::Data::Raw->new_from_xmlstring($frame); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub write_message |
98
|
|
|
|
|
|
|
{ |
99
|
0
|
|
|
0
|
0
|
|
my ($self,$to,$msg)=@_; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my $m=Net::DRI::Util::encode_utf8($msg); |
102
|
0
|
|
|
|
|
|
my $l=pack('N',4+length($m)); ## RFC 4934 §4 |
103
|
0
|
|
|
|
|
|
return $l.$m; ## We do not support EPP "0.4" at all (which lacks length before data) |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub transport_default |
107
|
|
|
|
|
|
|
{ |
108
|
0
|
|
|
0
|
0
|
|
my ($self,$tname)=@_; |
109
|
0
|
|
|
|
|
|
return (defer => 0, socktype => 'ssl', ssl_version => 'TLSv1', remote_port => 700); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# SSL_verify_callback |
113
|
|
|
|
|
|
|
# If you want to verify certificates yourself, you can pass a sub reference along with this parameter to do so. When the |
114
|
|
|
|
|
|
|
# callback is called, it will be passed: 1) a true/false value that indicates what OpenSSL thinks of the certificate, 2) |
115
|
|
|
|
|
|
|
# a C-style memory address of the certificate store, 3) a string containing the certificate's issuer attributes and owner |
116
|
|
|
|
|
|
|
# attributes, and 4) a string containing any errors encountered (0 if no errors). The function should return 1 or 0, |
117
|
|
|
|
|
|
|
# depending on whether it thinks the certificate is valid or invalid. The default is to let OpenSSL do all of the busy |
118
|
|
|
|
|
|
|
# work. |
119
|
|
|
|
|
|
|
## |
120
|
|
|
|
|
|
|
## (seems to be called twice) |
121
|
|
|
|
|
|
|
## |
122
|
|
|
|
|
|
|
## See also IO::Socket::SSL verify_hostname() |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
## TODO: implement TLS checkings as defined in RFC5734 §9 (test that $po->name() eq 'EPP' !) |
125
|
|
|
|
|
|
|
sub tls_verifications |
126
|
|
|
|
|
|
|
{ |
127
|
0
|
|
|
0
|
0
|
|
my ($to,$status,$store,$certowner,$errors)=@_; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
## From internals of IO::Socket::SSL : |
130
|
0
|
|
|
|
|
|
my $cert=Net::SSLeay::X509_STORE_CTX_get_current_cert($store); |
131
|
0
|
|
|
|
|
|
my $issuer= Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_issuer_name($cert)); |
132
|
0
|
|
|
|
|
|
my $subject=Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_subject_name($cert)); |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
print STDERR "TODO WIP\n"; |
135
|
0
|
|
|
|
|
|
print STDERR "ISSUER=$issuer\n"; |
136
|
0
|
|
|
|
|
|
print STDERR "SUBJECT=$subject\n"; |
137
|
0
|
|
|
|
|
|
print STDERR "STATUS=$status\n"; |
138
|
0
|
|
|
|
|
|
print STDERR "ERRORS=$errors\n"; ## self signed certificate is considered an error |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
return 1; ## 1 if certificate is valid, 0 otherwise |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
#################################################################################################### |
144
|
|
|
|
|
|
|
1; |