Imported Upstream version 1.01
Dominic Hargreaves
12 years ago
0 | 1.01 2012/01/31 | |
1 | Net::SSLGlue::LDAP as wrongly named Net::DNSGlue::LDAP | |
2 | ||
3 | 1.0 2012/01/30 | |
4 | Net::SSLGlue::SMTP: save hello domain from last hello call, so that the | |
5 | hello after the starttls uses the same domain argument. | |
6 | Thanks to zaucker[AT]oetiker[DOT]ch for reporting problem. | |
7 | ||
8 | 0.9 2012/01/24 | |
9 | Net::SSLGlue::SMTP: fixed stripping of port from host/ip for name | |
10 | verification. Added hello after successful starttls. Extented tests | |
11 | to check, if we can actually talk after starttls. | |
12 | Thanks to zaucker[AT]oetiker[DOT]ch for reporting problem. | |
13 | ||
0 | 14 | 0.8 2011/07/17 |
1 | 15 | fixed wrong position for include encode_base64 and uri_unescape in *::LWP. |
2 | 16 | Thanks to mtelle[AT]kamp-dsl[DOT]de for reporting |
0 | 0 | --- #YAML:1.0 |
1 | 1 | name: Net-SSLGlue |
2 | version: 0.8 | |
2 | version: 1.01 | |
3 | 3 | abstract: ~ |
4 | 4 | author: [] |
5 | 5 | license: unknown |
14 | 14 | directory: |
15 | 15 | - t |
16 | 16 | - inc |
17 | generated_by: ExtUtils::MakeMaker version 6.55_02 | |
17 | generated_by: ExtUtils::MakeMaker version 6.56 | |
18 | 18 | meta-spec: |
19 | 19 | url: http://module-build.sourceforge.net/META-spec-v1.4.html |
20 | 20 | version: 1.4 |
0 | 0 | use strict; |
1 | 1 | use warnings; |
2 | package Net::DNSGlue::LDAP; | |
3 | our $VERSION = 0.2; | |
2 | package Net::SSLGlue::LDAP; | |
3 | our $VERSION = '1.01'; | |
4 | 4 | use Net::LDAP; |
5 | 5 | use IO::Socket::SSL 1.19; |
6 | 6 |
3 | 3 | package Net::SSLGlue::SMTP; |
4 | 4 | use IO::Socket::SSL 1.19; |
5 | 5 | use Net::SMTP; |
6 | our $VERSION = 0.7; | |
6 | our $VERSION = 1.0; | |
7 | 7 | |
8 | 8 | ############################################################################## |
9 | 9 | # mix starttls method into Net::SMTP which on SSL handshake success |
12 | 12 | sub Net::SMTP::starttls { |
13 | 13 | my $self = shift; |
14 | 14 | $self->_STARTTLS or return; |
15 | my $host = ${*$self}{net_smtp_host}; | |
15 | my $host = $self->host; | |
16 | 16 | # for name verification strip port from domain:port, ipv4:port, [ipv6]:port |
17 | $host =~s{^(?:[^:]+|.+\])\:(\d+)$}{}; | |
17 | $host =~s{(?<!:):\d+$}{}; | |
18 | 18 | |
19 | 19 | Net::SMTP::_SSLified->start_SSL( $self, |
20 | 20 | SSL_verify_mode => 1, |
21 | 21 | SSL_verifycn_scheme => 'smtp', |
22 | 22 | SSL_verifycn_name => $host, |
23 | 23 | @_ |
24 | ); | |
24 | ) or return; | |
25 | ||
26 | # another hello after starttls to read new ESMTP capabilities | |
27 | return $self->hello(${*$self}{net_smtp_hello_domain}); | |
25 | 28 | } |
26 | 29 | sub Net::SMTP::_STARTTLS { |
27 | 30 | shift->command("STARTTLS")->response() == Net::SMTP::CMD_OK |
40 | 43 | } |
41 | 44 | }; |
42 | 45 | |
46 | my $old_hello = \&Net::SMTP::hello; | |
47 | *Net::SMTP::hello = sub { | |
48 | my ($self,$domain) = @_; | |
49 | ${*$self}{net_smtp_hello_domain} = $domain if $domain; | |
50 | goto &$old_hello; | |
51 | }; | |
52 | ||
43 | 53 | ############################################################################## |
44 | 54 | # Socket class derived from IO::Socket::SSL |
45 | 55 | # strict certificate verification per default |
56 | 66 | if ! exists $arg_hash->{SSL_verify_mode}; |
57 | 67 | $arg_hash->{SSL_verifycn_scheme} = 'smtp' |
58 | 68 | if ! exists $arg_hash->{SSL_verifycn_scheme}; |
59 | $arg_hash->{SSL_verifycn_name} = ${*$self}{net_smtp_host} | |
69 | $arg_hash->{SSL_verifycn_name} = $self->host | |
60 | 70 | if ! exists $arg_hash->{SSL_verifycn_name}; |
61 | 71 | |
62 | 72 | # force keys from %SSLopts |
32 | 32 | SSL_ca_path => $capath, |
33 | 33 | SSL_verify_mode => 1, |
34 | 34 | SSL_verifycn_scheme => 'smtp' |
35 | ) or do { | |
35 | ) or do { | |
36 | 36 | print "1..0 # mail.gmx.net:465 not reachable with SSL\n"; |
37 | 37 | exit |
38 | 38 | }; |
45 | 45 | SSL_ca_path => $capath, |
46 | 46 | SSL_verify_mode => 1, |
47 | 47 | SSL_verifycn_scheme => 'smtp' |
48 | ) and do { | |
48 | ) and do { | |
49 | 49 | print "1..0 # mail.gmx.de:465 reachable with SSL\n"; |
50 | 50 | exit |
51 | 51 | }; |
52 | 52 | |
53 | print "1..5\n"; | |
53 | print "1..6\n"; | |
54 | 54 | |
55 | 55 | # first direct SSL |
56 | 56 | my $smtp = Net::SMTP->new( 'mail.gmx.net', |
63 | 63 | $smtp = Net::SMTP->new( 'mail.gmx.net' ); |
64 | 64 | my $ok = $smtp->starttls( SSL_ca_path => $capath ); |
65 | 65 | print $ok ? "ok\n" : "not ok # smtp starttls mail.gmx.net\n"; |
66 | # check that we can talk on connection | |
67 | print $smtp->quit ? "ok\n": "not ok # quit failed\n"; | |
66 | 68 | |
67 | 69 | # against wrong host should fail |
68 | 70 | $smtp = Net::SMTP->new( 'mail.gmx.de' ); # should succeed |