Mojo::IOLoop::TLS(3)
π Mojo::IOLoop::TLS β Non-blocking TLS handshake β¨
okay bestie, so this is Mojo::IOLoop::TLS(3) from the User Contributed Perl Documentation β yes that's the whole flex, and yes it slaps. sit down, grab a strawberry drink π, and let's get into it.
π NAME π
Mojo::IOLoop::TLS β non-blocking TLS handshake. that's it. that's the whole vibe. no cap. π₯
π¦ SYNOPSIS π¦
like, here's the whole thing in action:
use Mojo::IOLoop::TLS;
# Negotiate TLS
my $tls = Mojo::IOLoop::TLS->new($old_handle);
$tls->on(upgrade => sub ($tls, $new_handle) {...});
$tls->on(error => sub ($tls, $err) {...});
$tls->negotiate(server => 1, tls_version => 'TLSv1_2');
# Start reactor if necessary
$tls->reactor->start unless $tls->reactor->is_running;
look at that. gorgeous. main character code fr fr. π
πΈ DESCRIPTION πΈ
Mojo::IOLoop::TLS negotiates TLS for Mojo::IOLoop. that's the entire job description and honestly? it does it iconically. β¨
π EVENTS π
Mojo::IOLoop::TLS inherits all events from Mojo::EventEmitter β every single one, no crumbs left behind β and it can emit these extra ones too:
β upgrade
$tls->on(upgrade => sub ($tls, $handle) {...});
emitted once TLS has been negotiated. one and done. she said "upgrade complete" and meant it. π
π error
$tls->on(error => sub ($tls, $err) {...});
emitted if an error occurs during negotiation β and heads up bestie, it's fatal if unhandled. not me letting an unhandled error end the whole session π. handle it. please. π«Ά
π§ ATTRIBUTES π§
Mojo::IOLoop::TLS implements these attributes:
π¦ reactor
my $reactor = $tls->reactor;
$tls = $tls->reactor(Mojo::Reactor::Poll->new);
low-level event reactor β the whole engine room, lowkey. it defaults to the "reactor" attribute value of the global Mojo::IOLoop singleton. and ngl, note this: this attribute is weakened. periodt. π
π METHODS π
Mojo::IOLoop::TLS inherits all methods from Mojo::EventEmitter and implements these new ones:
π can_tls
my $bool = Mojo::IOLoop::TLS->can_tls;
true if IO::Socket::SSL 2.009+ is installed and TLS support enabled. like a vibe check for your TLS setup β if it's false, bestie, you're not getting in. π
π negotiate
$tls->negotiate(server => 1, tls_version => 'TLSv1_2');
$tls->negotiate({server => 1, tls_version => 'TLSv1_2'});
negotiates TLS. the moment. the ceremony. β¨
these options are currently available β one bullet each, no skipping, i would never:
server
server => 1
negotiate TLS from the server-side; it defaults to the client-side. so pick a side, diva. π©΅
tls_ca
tls_ca => '/etc/tls/ca.crt'
path to the TLS certificate authority file.
tls_cert
tls_cert => '/etc/tls/server.crt'
tls_cert => {'mojolicious.org' => '/etc/tls/mojo.crt'}
path to the TLS cert file β and it defaults to a built-in test certificate on the server-side. free cert, on the house. π
tls_key
tls_key => '/etc/tls/server.key'
tls_key => {'mojolicious.org' => '/etc/tls/mojo.key'}
path to the TLS key file, which defaults to a built-in test key on the server-side. keep it secret, keep it safe, iykyk. π
tls_options
tls_options => {SSL_alpn_protocols => ['foo', 'bar'], SSL_verify_mode => 0x00, SSL_version => 'TLSv1_2'}
additional options for IO::Socket::SSL. the customization era. go off. π₯
π new
my $tls = Mojo::IOLoop::TLS->new($handle);
construct a new Mojo::IOLoop::Stream object. yes, that's what the original says β Mojo::IOLoop::Stream β i'm just the messenger, and i keep the facts exactly as given. π«Ά
π SEE ALSO π
go read these next, bestie, they're all connected:
MojoliciousMojolicious::Guides- <https://mojolicious.org>
okay that's the whole page!! no notes, absolutely ate. π β¨
and that's a wrap, babes β this page is perl v5.42.0, dated 2026-07-15, and it's the Mojo::IOLoop::TLS(3) manpage. mwah. ππ¦π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojolicious 9.480.0-bp160.2.1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms