1Mojo::IOLoop::TLS(3)  User Contributed Perl Documentation Mojo::IOLoop::TLS(3)
2
3
4

NAME

6       Mojo::IOLoop::TLS - Non-blocking TLS handshake
7

SYNOPSIS

9         use Mojo::IOLoop::TLS;
10
11         # Negotiate TLS
12         my $tls = Mojo::IOLoop::TLS->new($old_handle);
13         $tls->on(upgrade => sub ($tls, $new_handle) {...});
14         $tls->on(error => sub ($tls, $err) {...});
15         $tls->negotiate(server => 1, tls_version => 'TLSv1_2');
16
17         # Start reactor if necessary
18         $tls->reactor->start unless $tls->reactor->is_running;
19

DESCRIPTION

21       Mojo::IOLoop::TLS negotiates TLS for Mojo::IOLoop.
22

EVENTS

24       Mojo::IOLoop::TLS inherits all events from Mojo::EventEmitter and can
25       emit the following new ones.
26
27   upgrade
28         $tls->on(upgrade => sub ($tls, $handle) {...});
29
30       Emitted once TLS has been negotiated.
31
32   error
33         $tls->on(error => sub ($tls, $err) {...});
34
35       Emitted if an error occurs during negotiation, fatal if unhandled.
36

ATTRIBUTES

38       Mojo::IOLoop::TLS implements the following attributes.
39
40   reactor
41         my $reactor = $tls->reactor;
42         $tls        = $tls->reactor(Mojo::Reactor::Poll->new);
43
44       Low-level event reactor, defaults to the "reactor" attribute value of
45       the global Mojo::IOLoop singleton. Note that this attribute is
46       weakened.
47

METHODS

49       Mojo::IOLoop::TLS inherits all methods from Mojo::EventEmitter and
50       implements the following new ones.
51
52   can_tls
53         my $bool = Mojo::IOLoop::TLS->can_tls;
54
55       True if IO::Socket::SSL 2.009+ is installed and TLS support enabled.
56
57   negotiate
58         $tls->negotiate(server => 1, tls_version => 'TLSv1_2');
59         $tls->negotiate({server => 1, tls_version => 'TLSv1_2'});
60
61       Negotiate TLS.
62
63       These options are currently available:
64
65       server
66           server => 1
67
68         Negotiate TLS from the server-side, defaults to the client-side.
69
70       tls_ca
71           tls_ca => '/etc/tls/ca.crt'
72
73         Path to TLS certificate authority file.
74
75       tls_cert
76           tls_cert => '/etc/tls/server.crt'
77           tls_cert => {'mojolicious.org' => '/etc/tls/mojo.crt'}
78
79         Path to the TLS cert file, defaults to a built-in test certificate on
80         the server-side.
81
82       tls_key
83           tls_key => '/etc/tls/server.key'
84           tls_key => {'mojolicious.org' => '/etc/tls/mojo.key'}
85
86         Path to the TLS key file, defaults to a built-in test key on the
87         server-side.
88
89       tls_options
90           tls_options => {SSL_alpn_protocols => ['foo', 'bar'], SSL_verify_mode => 0x00, SSL_version => 'TLSv1_2'}
91
92         Additional options for IO::Socket::SSL.
93
94   new
95         my $tls = Mojo::IOLoop::TLS->new($handle);
96
97       Construct a new Mojo::IOLoop::Stream object.
98

SEE ALSO

100       Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
101
102
103
104perl v5.32.1                      2021-02-07              Mojo::IOLoop::TLS(3)
Impressum