1#!perl -w 2# Before `make install' is performed this script should be runnable with 3# `make test'. After `make install' it should work as `perl t/compatibility.t' 4 5use IO::Socket::SSL; 6use Socket; 7eval {require "t/ssl_settings.req";} || 8eval {require "ssl_settings.req";}; 9 10$|=1; 11 12foreach ($^O) { 13 if (/MacOS/ or /VOS/ or /vmesa/ or /riscos/ or /amigaos/) { 14 print "1..0 # Skipped: fork not implemented on this platform\n"; 15 exit; 16 } 17} 18 19$SIG{'CHLD'} = "IGNORE"; 20 21print "1..9\n"; 22IO::Socket::SSL::context_init(SSL_verify_mode => 0x01, SSL_version => 'TLSv1' ); 23 24 25my $server = IO::Socket::INET->new( 26 LocalAddr => $SSL_SERVER_ADDR, 27 Listen => 1, 28 Proto => 'tcp', ReuseAddr => 1, Timeout => 15 29); 30 31if (!$server) { 32 print "Bail out! "; 33 print("Setup of test IO::Socket::INET client and server failed. All the rest of ", 34 "the tests in this suite will fail also unless you change the values in ", 35 "ssl_settings.req in the t/ directory."); 36 exit; 37} 38 39my ($SSL_SERVER_PORT) = unpack_sockaddr_in( $server->sockname ); 40 41print "ok\n"; 42 43unless (fork) { 44 close $server; 45 $MyClass::client = new IO::Socket::INET("$SSL_SERVER_ADDR:$SSL_SERVER_PORT"); 46 package MyClass; 47 use IO::Socket::SSL; 48 @ISA = "IO::Socket::SSL"; 49 MyClass->start_SSL($client) || print "not "; 50 print "ok\n"; 51 (ref($client) eq "MyClass") || print "not "; 52 print "ok\n"; 53 $client->issuer_name || print "not "; 54 print "ok\n"; 55 $client->subject_name || print "not "; 56 print "ok\n"; 57 $client->opened || print "not "; 58 print "ok\n"; 59 print $client "Ok to close\n"; 60 close $client; 61 exit(0); 62} 63 64my $contact = $server->accept; 65 66IO::Socket::SSL::socketToSSL($contact, 67 {SSL_server => 1, 68 SSL_verify_mode => 0}) || print "not "; 69print "ok\n"; 70<$contact>; 71close $contact; 72close $server; 73 74bless $contact, "MyClass"; 75print "not " if IO::Socket::SSL::socket_to_SSL($contact, SSL_server => 1); 76print "ok\n"; 77 78print "not " unless (ref($contact) eq "MyClass"); 79print "ok\n"; 80 81sub bail { 82 print "Bail Out! $IO::Socket::SSL::ERROR"; 83} 84