Puhhh... now we've documented the prototypes of all 214 API "functions". This
[openssl.git] / perl / s2.pl
1 #!/usr/local/bin/perl
2
3 use ExtUtils::testlib;
4
5 use SSLeay;
6
7 $ssl_ctx=SSL::CTX->new("SSLv3");
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 $ssl=$ssl_ctx->new_ssl;
21 $sbio=BIO->new("ssl");
22 $sbio->set_ssl($ssl);
23 $ssl->set_options("-connect_state");
24
25 $bio=BIO->new("buffer");
26
27 $sbio->push($cbio);
28 $bio->push($sbio);
29
30 ($bio->do_handshake() > 0) || die $bio->error();
31
32 (($ret=$bio->syswrite("GET / HTTP/1.0\r\n\r\n")) > 0) || die $ssl->error();
33 $bio->flush() || die $bio->error();
34
35 $data="";
36 while ($_=$bio->getline())
37         {
38         if (/^Server:/)
39                 {
40                 print;
41                 last;
42                 }
43         }
44
45 if ($bio->peek_error())
46         {
47         print "There was an error:".$ssl->error();
48         }
49 print "exit\n";