# IO::Socket::SSL support code
package PublicInbox::TLS;
-use strict;
+use v5.12;
use IO::Socket::SSL;
use PublicInbox::Syscall qw(EPOLLIN EPOLLOUT);
use Carp qw(carp croak);
@{$tlsd->{ssl_ctx_opt}}, SSL_server => 1) or
croak "SSL_Context->new: $SSL_ERROR";
- # save ~34K per idle connection (cf. SSL_CTX_set_mode(3ssl))
+ # SSL_MODE_RELEASE_BUFFERS saves ~34K per idle connection
+ # (cf. SSL_CTX_set_mode(3ssl))
# RSS goes from 346MB to 171MB with 10K idle NNTPS clients on amd64
# cf. https://rt.cpan.org/Ticket/Display.html?id=129463
- my $mode = eval { Net::SSLeay::MODE_RELEASE_BUFFERS() };
- if ($mode && $ctx->{context}) {
+ # SSL_OP_NO_COMPRESSION should be the default in OpenSSL nowadays:
+ # it avoids the CRIME attack and zlib memory overhead
+ for my $f (qw(MODE_RELEASE_BUFFERS OP_NO_COMPRESSION)) {
+ my $mode = eval "Net::SSLeay::$f()" or next;
eval { Net::SSLeay::CTX_set_mode($ctx->{context}, $mode) };
- warn "W: $@ (setting SSL_MODE_RELEASE_BUFFERS)\n" if $@;
+ warn "W: $@ (setting SSL_$f)\n" if $@;
}
$ctx;
}