diff ssl_certificate.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 436d0ffc2ea3
children da52525f49d1
line wrap: on
line diff
--- a/ssl_certificate.t
+++ b/ssl_certificate.t
@@ -12,7 +12,7 @@ use strict;
 
 use Test::More;
 
-use Socket qw/ :DEFAULT CRLF /;
+use Socket qw/ CRLF /;
 
 BEGIN { use FindBin; chdir($FindBin::Bin); }
 
@@ -214,15 +214,8 @@ sub cert {
 
 sub get_ssl_socket {
 	my ($host, $port, $ses) = @_;
-	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);