2 # Before `make install' is performed this script should be runnable with
3 # `make test'. After `make install' it should work as `perl t/dhe.t'
5 # This tests the use of Diffie Hellman Key Exchange (DHE)
6 # If you have only a 384bit RSA key you can not use RSA key exchange,
7 # but DHE is usable. For an explanation see
8 # http://groups.google.de/group/mailing.openssl.users/msg/d60330cfa7a6034b
9 # So this test simple uses a 384bit RSA key to make sure that DHE is used.
17 if ( grep { $^O =~m{$_} } qw( MacOS VOS vmesa riscos amigaos ) ) {
18 print "1..0 # Skipped: fork not implemented on this platform\n";
25 # first create simple ssl-server
27 my $addr = '127.0.0.1';
28 my $server = IO::Socket::SSL->new(
32 SSL_cert_file => "certs/server-rsa384-dh.pem",
33 SSL_key_file => "certs/server-rsa384-dh.pem",
34 SSL_dh_file => "certs/server-rsa384-dh.pem",
39 ok("Server Initialization");
41 # add server port to addr
42 $addr.= ':'.(sockaddr_in( getsockname( $server )))[0];
45 if ( !defined $pid ) {
48 } elsif ( !$pid ) { ###### Client
52 my $to_server = IO::Socket::SSL->new( $addr ) || do {
53 notok( "connect failed: ".IO::Socket::SSL->errstr() );
56 ok( "client connected" );
58 } else { ###### Server
60 my $to_client = $server->accept || do {
61 notok( "accept failed: ".$server->errstr() );
65 ok( "Server accepted" );
69 sub ok { print "ok # [$ID] @_\n"; }
70 sub notok { print "not ok # [$ID] @_\n"; }