diff ssl_certificate_perl.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 144c6ce732e4
children 58951cf933e1
line wrap: on
line diff
--- a/ssl_certificate_perl.t
+++ b/ssl_certificate_perl.t
@@ -12,8 +12,6 @@ use strict;
 
 use Test::More;
 
-use Socket;
-
 BEGIN { use FindBin; chdir($FindBin::Bin); }
 
 use lib 'lib';
@@ -114,15 +112,8 @@ sub cert {
 
 sub get_ssl_socket {
 	my ($host, $port) = @_;
-	my $s;
 
-	my $dest_ip = inet_aton('127.0.0.1');
-	$port = port($port);
-	my $dest_serv_params = sockaddr_in($port, $dest_ip);
-
-	socket($s, &AF_INET, &SOCK_STREAM, 0) or die "socket: $!";
-	connect($s, $dest_serv_params) or die "connect: $!";
-
+	my $s = IO::Socket::INET->new('127.0.0.1:' . port($port));
 	my $ctx = Net::SSLeay::CTX_new() or die("Failed to create SSL_CTX $!");
 	my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!");
 	Net::SSLeay::set_tlsext_host_name($ssl, $host);