.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mojo::IOLoop::TLS 3pm" .TH Mojo::IOLoop::TLS 3pm 2024-05-15 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Mojo::IOLoop::TLS \- Non\-blocking TLS handshake .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& 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 => \*(AqTLSv1_2\*(Aq); \& \& # Start reactor if necessary \& $tls\->reactor\->start unless $tls\->reactor\->is_running; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Mojo::IOLoop::TLS negotiates TLS for Mojo::IOLoop. .SH EVENTS .IX Header "EVENTS" Mojo::IOLoop::TLS inherits all events from Mojo::EventEmitter and can emit the following new ones. .SS upgrade .IX Subsection "upgrade" .Vb 1 \& $tls\->on(upgrade => sub ($tls, $handle) {...}); .Ve .PP Emitted once TLS has been negotiated. .SS error .IX Subsection "error" .Vb 1 \& $tls\->on(error => sub ($tls, $err) {...}); .Ve .PP Emitted if an error occurs during negotiation, fatal if unhandled. .SH ATTRIBUTES .IX Header "ATTRIBUTES" Mojo::IOLoop::TLS implements the following attributes. .SS reactor .IX Subsection "reactor" .Vb 2 \& my $reactor = $tls\->reactor; \& $tls = $tls\->reactor(Mojo::Reactor::Poll\->new); .Ve .PP Low-level event reactor, defaults to the \f(CW\*(C`reactor\*(C'\fR attribute value of the global Mojo::IOLoop singleton. Note that this attribute is weakened. .SH METHODS .IX Header "METHODS" Mojo::IOLoop::TLS inherits all methods from Mojo::EventEmitter and implements the following new ones. .SS can_tls .IX Subsection "can_tls" .Vb 1 \& my $bool = Mojo::IOLoop::TLS\->can_tls; .Ve .PP True if IO::Socket::SSL 2.009+ is installed and TLS support enabled. .SS negotiate .IX Subsection "negotiate" .Vb 2 \& $tls\->negotiate(server => 1, tls_version => \*(AqTLSv1_2\*(Aq); \& $tls\->negotiate({server => 1, tls_version => \*(AqTLSv1_2\*(Aq}); .Ve .PP Negotiate TLS. .PP These options are currently available: .IP server 2 .IX Item "server" .Vb 1 \& server => 1 .Ve .Sp Negotiate TLS from the server-side, defaults to the client-side. .IP tls_ca 2 .IX Item "tls_ca" .Vb 1 \& tls_ca => \*(Aq/etc/tls/ca.crt\*(Aq .Ve .Sp Path to TLS certificate authority file. .IP tls_cert 2 .IX Item "tls_cert" .Vb 2 \& tls_cert => \*(Aq/etc/tls/server.crt\*(Aq \& tls_cert => {\*(Aqmojolicious.org\*(Aq => \*(Aq/etc/tls/mojo.crt\*(Aq} .Ve .Sp Path to the TLS cert file, defaults to a built-in test certificate on the server-side. .IP tls_key 2 .IX Item "tls_key" .Vb 2 \& tls_key => \*(Aq/etc/tls/server.key\*(Aq \& tls_key => {\*(Aqmojolicious.org\*(Aq => \*(Aq/etc/tls/mojo.key\*(Aq} .Ve .Sp Path to the TLS key file, defaults to a built-in test key on the server-side. .IP tls_options 2 .IX Item "tls_options" .Vb 1 \& tls_options => {SSL_alpn_protocols => [\*(Aqfoo\*(Aq, \*(Aqbar\*(Aq], SSL_verify_mode => 0x00, SSL_version => \*(AqTLSv1_2\*(Aq} .Ve .Sp Additional options for IO::Socket::SSL. .SS new .IX Subsection "new" .Vb 1 \& my $tls = Mojo::IOLoop::TLS\->new($handle); .Ve .PP Construct a new Mojo::IOLoop::Stream object. .SH "SEE ALSO" .IX Header "SEE ALSO" Mojolicious, Mojolicious::Guides, .