Codebase list libnet-sslglue-perl / d840fc8
Imported Upstream version 1.01 Dominic Hargreaves 12 years ago
6 changed file(s) with 39 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
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
014 0.8 2011/07/17
115 fixed wrong position for include encode_base64 and uri_unescape in *::LWP.
216 Thanks to mtelle[AT]kamp-dsl[DOT]de for reporting
00 --- #YAML:1.0
11 name: Net-SSLGlue
2 version: 0.8
2 version: 1.01
33 abstract: ~
44 author: []
55 license: unknown
1414 directory:
1515 - t
1616 - inc
17 generated_by: ExtUtils::MakeMaker version 6.55_02
17 generated_by: ExtUtils::MakeMaker version 6.56
1818 meta-spec:
1919 url: http://module-build.sourceforge.net/META-spec-v1.4.html
2020 version: 1.4
00 use strict;
11 use warnings;
2 package Net::DNSGlue::LDAP;
3 our $VERSION = 0.2;
2 package Net::SSLGlue::LDAP;
3 our $VERSION = '1.01';
44 use Net::LDAP;
55 use IO::Socket::SSL 1.19;
66
33 package Net::SSLGlue::SMTP;
44 use IO::Socket::SSL 1.19;
55 use Net::SMTP;
6 our $VERSION = 0.7;
6 our $VERSION = 1.0;
77
88 ##############################################################################
99 # mix starttls method into Net::SMTP which on SSL handshake success
1212 sub Net::SMTP::starttls {
1313 my $self = shift;
1414 $self->_STARTTLS or return;
15 my $host = ${*$self}{net_smtp_host};
15 my $host = $self->host;
1616 # for name verification strip port from domain:port, ipv4:port, [ipv6]:port
17 $host =~s{^(?:[^:]+|.+\])\:(\d+)$}{};
17 $host =~s{(?<!:):\d+$}{};
1818
1919 Net::SMTP::_SSLified->start_SSL( $self,
2020 SSL_verify_mode => 1,
2121 SSL_verifycn_scheme => 'smtp',
2222 SSL_verifycn_name => $host,
2323 @_
24 );
24 ) or return;
25
26 # another hello after starttls to read new ESMTP capabilities
27 return $self->hello(${*$self}{net_smtp_hello_domain});
2528 }
2629 sub Net::SMTP::_STARTTLS {
2730 shift->command("STARTTLS")->response() == Net::SMTP::CMD_OK
4043 }
4144 };
4245
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
4353 ##############################################################################
4454 # Socket class derived from IO::Socket::SSL
4555 # strict certificate verification per default
5666 if ! exists $arg_hash->{SSL_verify_mode};
5767 $arg_hash->{SSL_verifycn_scheme} = 'smtp'
5868 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
6070 if ! exists $arg_hash->{SSL_verifycn_name};
6171
6272 # force keys from %SSLopts
00 package Net::SSLGlue;
1 our $VERSION = 0.8;
1 our $VERSION = '1.01';
22
33 =head1 NAME
44
3232 SSL_ca_path => $capath,
3333 SSL_verify_mode => 1,
3434 SSL_verifycn_scheme => 'smtp'
35 ) or do {
35 ) or do {
3636 print "1..0 # mail.gmx.net:465 not reachable with SSL\n";
3737 exit
3838 };
4545 SSL_ca_path => $capath,
4646 SSL_verify_mode => 1,
4747 SSL_verifycn_scheme => 'smtp'
48 ) and do {
48 ) and do {
4949 print "1..0 # mail.gmx.de:465 reachable with SSL\n";
5050 exit
5151 };
5252
53 print "1..5\n";
53 print "1..6\n";
5454
5555 # first direct SSL
5656 my $smtp = Net::SMTP->new( 'mail.gmx.net',
6363 $smtp = Net::SMTP->new( 'mail.gmx.net' );
6464 my $ok = $smtp->starttls( SSL_ca_path => $capath );
6565 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";
6668
6769 # against wrong host should fail
6870 $smtp = Net::SMTP->new( 'mail.gmx.de' ); # should succeed