"Fossies" - the Fresh Open Source Software Archive 
Member "memcached-1.6.15/t/ssl_proto_version.t" (21 Feb 2022, 1180 Bytes) of package /linux/www/memcached-1.6.15.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 #!/usr/bin/perl
2
3 use warnings;
4 use Test::More;
5 use FindBin qw($Bin);
6 use lib "$Bin/lib";
7 use MemcachedTest;
8
9 if (!enabled_tls_testing()) {
10 plan skip_all => 'SSL testing is not enabled';
11 exit 0;
12 }
13
14 my $server;
15 my $is_tls_13_available = 0;
16
17 eval {
18 # ssl_min_version=3 is not recognized when compiled with OpenSSL < 1.1.1
19 $server = new_memcached('-o ssl_min_version=3');
20 $is_tls_13_available = 1;
21 };
22
23 SKIP: {
24 skip 'TLS v1.3 not available', 1 if !$is_tls_13_available;
25 # Unsupported protocol version
26 $sock = $server->new_sock(undef, 'TLSv1_2');
27 is(undef, $sock, "handshake failure on unsupported proto version");
28 }
29
30 $server = new_memcached('-o ssl_min_version=2');
31
32 # Minimum supported protocol version
33 $sock = $server->new_sock(undef, 'TLSv1_2');
34 print $sock "version\r\n";
35 like(scalar <$sock>, qr/VERSION/, "handshake with minimum proto version");
36
37 SKIP: {
38 skip 'TLS v1.3 not available', 1 if !$is_tls_13_available;
39 # Above minimum supported protocol version
40 $sock = $server->new_sock(undef, 'TLSv1_3');
41 print $sock "version\r\n";
42 like(scalar <$sock>, qr/VERSION/, "handshake above minimum proto version");
43 }
44
45 done_testing();