2
# a test server for testing IO::Socket::SSL-class's behavior
5
# $Id: ssl_server.pl,v 1.7 2000/11/08 09:25:21 aspa Exp $.
12
my ($sock, $s, $v_mode);
14
if($ARGV[0] eq "DEBUG") { $IO::Socket::SSL::DEBUG = 1; }
17
if(!($sock = IO::Socket::SSL->new( Listen => 5,
18
LocalAddr => 'localhost',
22
SSL_verify_mode => 0x01,
24
print STDERR "unable to create socket: $!.\n";
27
print STDERR "socket created: $sock.\n";
30
print STDERR "waiting for next connection.\n";
32
while(($s = $sock->accept())) {
33
my ($peer_cert, $subject_name, $issuer_name, $date, $str);
36
print STDERR "error: '$!'.\n";
40
print STDERR "connection opened ($s).\n";
42
if( ref($sock) eq "IO::Socket::SSL") {
43
if(($peer_cert = $s->get_peer_certificate())) {
44
$subject_name = $peer_cert->subject_name;
45
$issuer_name = $peer_cert->issuer_name;
48
print STDERR "\t subject: '$subject_name'.\n";
49
print STDERR "\t issuer: '$issuer_name'.\n";
52
$date = `date`; chop $date;
53
$str = "my date command says it's: '$date'";
54
$s->write($str, length($str));
57
print STDERR "\t connection closed.\n";
64
print STDERR "loop exited.\n";