This commit was generated by cvs2svn to track changes on a CVS vendor
[openssl.git] / perl / s.pl
1 #!/usr/local/bin/perl
2
3 use ExtUtils::testlib;
4
5 use SSLeay;
6
7 $ssl_ctx=SSL::CTX->new("SSLv3_client");
8
9 $ssl_ctx->set_options("-info_callback" =>
10         sub     {
11                 print STDERR $_[0]->state()."\n";
12                 }
13         );
14
15 $conn="localhost:4433";
16 $conn=$ARGV[0] if $#ARGV >= 0;
17 $cbio=BIO->new("connect");
18 $cbio->hostname($conn) || die $ssl->error();
19
20 $bbio=BIO->new("buffer");
21
22 $sbio=BIO->new("ssl");
23 $ssl=$ssl_ctx->new_ssl;
24 $ssl->set_options(-connect_state);
25 $sbio->set_ssl($ssl);
26
27 $sbio->push($cbio);
28 $bbio->push($sbio);
29 $bio=$bbio;
30
31 #$bio->set_callback(
32 #       sub     {
33 #               my($bio,$state,$cmd,$buf,$lart,$ret)=@_;
34 #               print STDERR "$state:$cmd\n";
35 #               return($ret);
36 #               }
37 #       );
38
39 $b=$bio;
40 do      {
41         print STDERR $b->type."\n";
42         } while ($b=$b->next_bio);
43
44 (($ret=$bio->syswrite("GET / HTTP/1.0\r\n\r\n")) > 0) || die $bio->error();
45 $bio->flush;
46
47 $data="";
48 while (1)
49         {
50         $ret=$bio->getline;
51         $ret =~ s/[\r\n]//g;
52         print STDERR "$ret\n";
53         last if $ret eq "";
54         $server=$1 if $ret=~ /^Server: (.*)/;
55         }
56
57
58 print "server is $server\n";
59 $x509=$ssl->get_peer_certificate();
60 print "version     :".$x509->get_version()."\n";
61 print "serialNumber:".$x509->get_serialNumber()->bn2hex."\n";
62 print "subject     :".$x509->get_subject_name()."\n";
63 print "issuer      :". $x509->get_issuer_name()."\n";
64
65 $c=$ssl->get_current_cipher;
66 ($i,$a)=$c->get_bits;
67 $v=$c->get_version;
68 $n=$c->get_name;
69
70 print "protocol=".$ssl->get_version."\n";
71 print "bits=$i($a) cipher type=$v cipher=$n\n";
72