Mercurial > hg > nginx-tests
comparison ssl_curve.t @ 1866:a797d7428fa5
Tests: simplified http SSL tests with IO::Socket::SSL.
The http SSL tests which previously used IO::Socket::SSL were converted
to use improved IO::Socket::SSL infrastructure in Test::Nginx.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 18 May 2023 18:07:19 +0300 |
parents | 58951cf933e1 |
children | 6bafe9419126 |
comparison
equal
deleted
inserted
replaced
1865:0e1865aa9b33 | 1866:a797d7428fa5 |
---|---|
73 | 73 |
74 $t->try_run('no $ssl_curve')->plan(1); | 74 $t->try_run('no $ssl_curve')->plan(1); |
75 | 75 |
76 ############################################################################### | 76 ############################################################################### |
77 | 77 |
78 like(get('/curve'), qr/^prime256v1 /m, 'ssl curve'); | 78 like(http_get('/curve', SSL => 1), qr/^prime256v1 /m, 'ssl curve'); |
79 | 79 |
80 ############################################################################### | 80 ############################################################################### |
81 | |
82 sub get { | |
83 my ($uri, $port, $ctx) = @_; | |
84 my $s = get_ssl_socket($port) or return; | |
85 my $r = http_get($uri, socket => $s); | |
86 $s->close(); | |
87 return $r; | |
88 } | |
89 | |
90 sub get_ssl_socket { | |
91 my ($port, $ctx) = @_; | |
92 my $s; | |
93 | |
94 eval { | |
95 local $SIG{ALRM} = sub { die "timeout\n" }; | |
96 local $SIG{PIPE} = sub { die "sigpipe\n" }; | |
97 alarm(8); | |
98 $s = IO::Socket::SSL->new( | |
99 Proto => 'tcp', | |
100 PeerAddr => '127.0.0.1', | |
101 PeerPort => port(8443), | |
102 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(), | |
103 SSL_error_trap => sub { die $_[1] }, | |
104 ); | |
105 alarm(0); | |
106 }; | |
107 alarm(0); | |
108 | |
109 if ($@) { | |
110 log_in("died: $@"); | |
111 return undef; | |
112 } | |
113 | |
114 return $s; | |
115 } | |
116 | |
117 ############################################################################### |