Mercurial > hg > nginx-tests
comparison stream_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 | f3ba4c74de31 |
children | 818e6d8c43b5 |
comparison
equal
deleted
inserted
replaced
1620:166461f0bd4b | 1621:fd440d324700 |
---|---|
10 | 10 |
11 use warnings; | 11 use warnings; |
12 use strict; | 12 use strict; |
13 | 13 |
14 use Test::More; | 14 use Test::More; |
15 | |
16 use Socket; | |
17 | 15 |
18 BEGIN { use FindBin; chdir($FindBin::Bin); } | 16 BEGIN { use FindBin; chdir($FindBin::Bin); } |
19 | 17 |
20 use lib 'lib'; | 18 use lib 'lib'; |
21 use Test::Nginx; | 19 use Test::Nginx; |
140 ############################################################################### | 138 ############################################################################### |
141 | 139 |
142 sub get { | 140 sub get { |
143 my ($port, $cert) = @_; | 141 my ($port, $cert) = @_; |
144 | 142 |
145 my $dest_ip = inet_aton('127.0.0.1'); | 143 my $s = IO::Socket::INET->new('127.0.0.1:' . port($port)); |
146 my $dest_serv_params = sockaddr_in(port($port), $dest_ip); | |
147 | |
148 socket(my $s, &AF_INET, &SOCK_STREAM, 0) or die "socket: $!"; | |
149 connect($s, $dest_serv_params) or die "connect: $!"; | |
150 | |
151 my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!"); | 144 my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!"); |
152 Net::SSLeay::set_cert_and_key($ctx, "$d/$cert.crt", "$d/$cert.key") | 145 Net::SSLeay::set_cert_and_key($ctx, "$d/$cert.crt", "$d/$cert.key") |
153 or die if $cert; | 146 or die if $cert; |
154 my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!"); | 147 my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!"); |
155 Net::SSLeay::set_fd($ssl, fileno($s)); | 148 Net::SSLeay::set_fd($ssl, fileno($s)); |