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 {
14           my ($tls, $new_handle) = @_;
15           ...
16         });
17         $tls->on(error => sub {
18           my ($tls, $err) = @_;
19           ...
20         });
21         $tls->negotiate(server => 1, tls_version => 'TLSv1_2');
22
23         # Start reactor if necessary
24         $tls->reactor->start unless $tls->reactor->is_running;
25

DESCRIPTION

27       Mojo::IOLoop::TLS negotiates TLS for Mojo::IOLoop.
28

EVENTS

30       Mojo::IOLoop::TLS inherits all events from Mojo::EventEmitter and can
31       emit the following new ones.
32
33   upgrade
34         $tls->on(upgrade => sub {
35           my ($tls, $handle) = @_;
36           ...
37         });
38
39       Emitted once TLS has been negotiated.
40
41   error
42         $tls->on(error => sub {
43           my ($tls, $err) = @_;
44           ...
45         });
46
47       Emitted if an error occurs during negotiation, fatal if unhandled.
48

ATTRIBUTES

50       Mojo::IOLoop::TLS implements the following attributes.
51
52   reactor
53         my $reactor = $tls->reactor;
54         $tls        = $tls->reactor(Mojo::Reactor::Poll->new);
55
56       Low-level event reactor, defaults to the "reactor" attribute value of
57       the global Mojo::IOLoop singleton. Note that this attribute is
58       weakened.
59

METHODS

61       Mojo::IOLoop::TLS inherits all methods from Mojo::EventEmitter and
62       implements the following new ones.
63
64   can_tls
65         my $bool = Mojo::IOLoop::TLS->can_tls;
66
67       True if IO::Socket::SSL 2.009+ is installed and TLS support enabled.
68
69   negotiate
70         $tls->negotiate(server => 1, tls_version => 'TLSv1_2');
71         $tls->negotiate({server => 1, tls_version => 'TLSv1_2'});
72
73       Negotiate TLS.
74
75       These options are currently available:
76
77       server
78           server => 1
79
80         Negotiate TLS from the server-side, defaults to the client-side.
81
82       tls_ca
83           tls_ca => '/etc/tls/ca.crt'
84
85         Path to TLS certificate authority file.
86
87       tls_cert
88           tls_cert => '/etc/tls/server.crt'
89           tls_cert => {'mojolicious.org' => '/etc/tls/mojo.crt'}
90
91         Path to the TLS cert file, defaults to a built-in test certificate on
92         the server-side.
93
94       tls_ciphers
95           tls_ciphers => 'AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH'
96
97         TLS cipher specification string. For more information about the
98         format see
99         <https://www.openssl.org/docs/manmaster/apps/ciphers.html#CIPHER-STRINGS>.
100
101       tls_key
102           tls_key => '/etc/tls/server.key'
103           tls_key => {'mojolicious.org' => '/etc/tls/mojo.key'}
104
105         Path to the TLS key file, defaults to a built-in test key on the
106         server-side.
107
108       tls_protocols
109           tls_protocols => ['foo', 'bar']
110
111         ALPN protocols to negotiate.
112
113       tls_verify
114           tls_verify => 0x00
115
116         TLS verification mode.
117
118       tls_version
119           tls_version => 'TLSv1_2'
120
121         TLS protocol version.
122
123   new
124         my $tls = Mojo::IOLoop::TLS->new($handle);
125
126       Construct a new Mojo::IOLoop::Stream object.
127

SEE ALSO

129       Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
130
131
132
133perl v5.32.0                      2020-07-28              Mojo::IOLoop::TLS(3)
Impressum