blob: 554a8dbeac3dc09ebdd5b295c4696845fc769eda (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!perl
use 5.008001;
use strict;
use warnings;
use Net::POP3;
use Test::More;
my $host = 'pop.gmx.net';
my $debug = 0;
plan skip_all => "no SSL support" if ! Net::POP3->can_ssl;
{
no warnings 'once';
plan skip_all => "no verified SSL connection to $host:995 - $@" if ! eval {
IO::Socket::SSL->new(PeerAddr => "$host:995", Timeout => 10)
|| die($IO::Socket::SSL::SSL_ERROR||$!);
};
}
plan tests => 2;
SKIP: {
diag( "connect inet to $host:110" );
skip "no inet connect to $host:110",1
if ! IO::Socket::INET->new(PeerAddr => "$host:110", Timeout => 10);
my $pop3 = Net::POP3->new($host, Debug => $debug, Timeout => 10)
or skip "normal POP3 failed: $@",1;
skip "no STARTTLS support",1 if $pop3->message !~/STARTTLS/;
if (!$pop3->starttls) {
fail("starttls failed: ".$pop3->code." $@")
} else {
# we now should have access to SSL stuff
my $cipher = eval { $pop3->get_cipher };
if (!$cipher) {
fail("after starttls: not an SSL object");
} elsif ( $pop3->quit ) {
pass("starttls + quit ok, cipher=$cipher");
} else {
fail("quit after starttls failed: ".$pop3->code);
}
}
}
my $pop3 = Net::POP3->new($host, SSL => 1, Timeout => 10, Debug => $debug);
# we now should have access to SSL stuff
my $cipher = eval { $pop3->get_cipher };
if (!$cipher) {
fail("after ssl connect: not an SSL object");
} elsif ( $pop3->quit ) {
pass("ssl connect ok, cipher=$cipher");
} else {
fail("quit after direct ssl failed: ".$pop3->code);
}
|