Mercurial > hg > nginx-tests
comparison ssl_verify_client.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 | f55d25e08b3e |
children | dc89eb420196 |
comparison
equal
deleted
inserted
replaced
1620:166461f0bd4b | 1621:fd440d324700 |
---|---|
10 use warnings; | 10 use warnings; |
11 use strict; | 11 use strict; |
12 | 12 |
13 use Test::More; | 13 use Test::More; |
14 | 14 |
15 use Socket qw/ :DEFAULT CRLF /; | 15 use Socket qw/ CRLF /; |
16 | 16 |
17 BEGIN { use FindBin; chdir($FindBin::Bin); } | 17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
18 | 18 |
19 use lib 'lib'; | 19 use lib 'lib'; |
20 use Test::Nginx; | 20 use Test::Nginx; |
183 | 183 |
184 local $SIG{PIPE} = 'IGNORE'; | 184 local $SIG{PIPE} = 'IGNORE'; |
185 | 185 |
186 $host = $sni if !defined $host; | 186 $host = $sni if !defined $host; |
187 | 187 |
188 my $dest_ip = inet_aton('127.0.0.1'); | 188 my $s = IO::Socket::INET->new('127.0.0.1:' . port(8081)); |
189 my $dest_serv_params = sockaddr_in(port(8081), $dest_ip); | |
190 | |
191 socket(my $s, &AF_INET, &SOCK_STREAM, 0) or die "socket: $!"; | |
192 connect($s, $dest_serv_params) or die "connect: $!"; | |
193 | |
194 my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!"); | 189 my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!"); |
195 Net::SSLeay::set_cert_and_key($ctx, "$d/$cert.crt", "$d/$cert.key") | 190 Net::SSLeay::set_cert_and_key($ctx, "$d/$cert.crt", "$d/$cert.key") |
196 or die if $cert; | 191 or die if $cert; |
197 my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!"); | 192 my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!"); |
198 Net::SSLeay::set_tlsext_host_name($ssl, $sni) == 1 or die; | 193 Net::SSLeay::set_tlsext_host_name($ssl, $sni) == 1 or die; |