Mercurial > hg > nginx-tests
comparison stream_ssl_variables.t @ 1621:fd440d324700
Tests: simplified get_ssl_socket() functions that use Net::SSLeay.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 24 Nov 2020 00:43:56 +0000 |
parents | f3ba4c74de31 |
children | 3f155fe97521 |
comparison
equal
deleted
inserted
replaced
1620:166461f0bd4b | 1621:fd440d324700 |
---|---|
9 | 9 |
10 use warnings; | 10 use warnings; |
11 use strict; | 11 use strict; |
12 | 12 |
13 use Test::More; | 13 use Test::More; |
14 | |
15 use Socket; | |
16 | 14 |
17 BEGIN { use FindBin; chdir($FindBin::Bin); } | 15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
18 | 16 |
19 use lib 'lib'; | 17 use lib 'lib'; |
20 use Test::Nginx; | 18 use Test::Nginx; |
125 | 123 |
126 ############################################################################### | 124 ############################################################################### |
127 | 125 |
128 sub get_ssl_socket { | 126 sub get_ssl_socket { |
129 my ($port, $ses, $name) = @_; | 127 my ($port, $ses, $name) = @_; |
130 my $s; | |
131 | 128 |
132 my $dest_ip = inet_aton('127.0.0.1'); | 129 my $s = IO::Socket::INET->new('127.0.0.1:' . $port); |
133 my $dest_serv_params = sockaddr_in($port, $dest_ip); | |
134 | |
135 socket($s, &AF_INET, &SOCK_STREAM, 0) or die "socket: $!"; | |
136 connect($s, $dest_serv_params) or die "connect: $!"; | |
137 | |
138 my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!"); | 130 my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!"); |
139 my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!"); | 131 my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!"); |
140 Net::SSLeay::set_tlsext_host_name($ssl, $name) if defined $name; | 132 Net::SSLeay::set_tlsext_host_name($ssl, $name) if defined $name; |
141 Net::SSLeay::set_session($ssl, $ses) if defined $ses; | 133 Net::SSLeay::set_session($ssl, $ses) if defined $ses; |
142 Net::SSLeay::set_fd($ssl, fileno($s)); | 134 Net::SSLeay::set_fd($ssl, fileno($s)); |