Skip to content

Commit 3fdfd7e

Browse files
authored
GH-89 Add support for TLSv1.3 via $Net::SSLeay::ssl_version. (#90)
1 parent 3bcbb3a commit 3fdfd7e

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Revision history for Perl extension Net::SSLeay.
6666
Debian Perl Group. This function now returns errors from
6767
library's error stack only when an underlying routine
6868
fails. Unrelated errors are now skipped. Fixes RT#126988.
69+
- Add support for TLSv1.3 via $Net::SSLeay::ssl_version.
6970
- Enhance t/local/43_misc_functions.t get_keyblock_size test
7071
to work better with AEAD ciphers.
7172
- Add constants SSL_OP_ENABLE_MIDDLEBOX_COMPAT and

lib/Net/SSLeay.pm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ $Net::SSLeay::trace = 0; # Do not change here, use
3434
# 10 = insist on TLSv1
3535
# 11 = insist on TLSv1.1
3636
# 12 = insist on TLSv1.2
37+
# 13 = insist on TLSv1.3
3738
# 0 or undef = guess (v23)
3839
#
3940
$Net::SSLeay::ssl_version = 0; # don't change here, use
@@ -1008,6 +1009,21 @@ sub new_x_ctx {
10081009
}
10091010
$ctx = CTX_tlsv1_2_new;
10101011
}
1012+
elsif ($ssl_version == 13) {
1013+
unless (eval { Net::SSLeay::TLS1_3_VERSION(); } ) {
1014+
warn "ssl_version has been set to 13, but this version of OpenSSL has been compiled without TLSv1.3 support";
1015+
return undef;
1016+
}
1017+
$ctx = CTX_new();
1018+
unless(Net::SSLeay::CTX_set_min_proto_version($ctx, Net::SSLeay::TLS1_3_VERSION())) {
1019+
warn "CTX_set_min_proto failed for TLSv1.3";
1020+
return undef;
1021+
}
1022+
unless(Net::SSLeay::CTX_set_max_proto_version($ctx, Net::SSLeay::TLS1_3_VERSION())) {
1023+
warn "CTX_set_max_proto failed for TLSv1.3";
1024+
return undef;
1025+
}
1026+
}
10111027
else { $ctx = CTX_new(); }
10121028
return $ctx;
10131029
}

lib/Net/SSLeay.pod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9321,7 +9321,7 @@ have rather complex interfaces with function pointers and all. In these
93219321
cases you should proceed wit great caution.
93229322

93239323
This module defaults to using OpenSSL automatic protocol negotiation
9324-
code for automatically detecting the version of the SSL protocol
9324+
code for automatically detecting the version of the SSL/TLS protocol
93259325
that the other end talks. With most web servers this works just
93269326
fine, but once in a while I get complaints from people that the module
93279327
does not work with some web servers. Usually this can be solved
@@ -9330,6 +9330,9 @@ by explicitly setting the protocol version, e.g.
93309330
$Net::SSLeay::ssl_version = 2; # Insist on SSLv2
93319331
$Net::SSLeay::ssl_version = 3; # Insist on SSLv3
93329332
$Net::SSLeay::ssl_version = 10; # Insist on TLSv1
9333+
$Net::SSLeay::ssl_version = 11; # Insist on TLSv1.1
9334+
$Net::SSLeay::ssl_version = 12; # Insist on TLSv1.2
9335+
$Net::SSLeay::ssl_version = 13; # Insist on TLSv1.3
93339336

93349337
Although the autonegotiation is nice to have, the SSL standards
93359338
do not formally specify any such mechanism. Most of the world has

0 commit comments

Comments
 (0)