@@ -14,7 +14,7 @@ plan skip_all => 'IO::Socket::SSL 2.009+ required for this test!' unless Moj
14
14
# openssl req -x509 -days 7300 -key ca.key -in ca.csr -out ca.crt
15
15
#
16
16
# openssl genrsa -out server.key 1024
17
- # openssl req -new -key server.key -out server.csr -subj "/C=US/CN=127.0.0.1 "
17
+ # openssl req -new -key server.key -out server.csr -subj "/C=US/CN=localhost "
18
18
# openssl x509 -req -days 7300 -in server.csr -out server.crt -CA ca.crt \
19
19
# -CAkey ca.key -CAcreateserial
20
20
#
@@ -36,7 +36,7 @@ utf8::upgrade $upgraded;
36
36
my ($server , $client );
37
37
my $promise = Mojo::Promise-> new-> ioloop($loop );
38
38
my $id = $loop -> server(
39
- {address => ' 127.0.0.1 ' , tls => 1} => sub {
39
+ {address => ' localhost ' , tls => 1} => sub {
40
40
my ($loop , $stream ) = @_ ;
41
41
$stream -> write ($upgraded => sub { shift -> write (' 321' ) });
42
42
$stream -> on(close => sub { $promise -> resolve });
@@ -46,7 +46,7 @@ my $id = $loop->server(
46
46
my $port = $loop -> acceptor($id )-> port;
47
47
my $promise2 = Mojo::Promise-> new-> ioloop($loop );
48
48
$loop -> client(
49
- {port => $port , tls => 1, tls_options => {SSL_verify_mode => 0x00}} => sub {
49
+ {address => ' localhost ' , port => $port , tls => 1, tls_options => {SSL_verify_mode => 0x00}} => sub {
50
50
my ($loop , $err , $stream ) = @_ ;
51
51
$stream -> write (' tset' => sub { shift -> write (' 123' ) });
52
52
$stream -> on(close => sub { $promise2 -> resolve });
@@ -64,7 +64,7 @@ my ($remove, $running, $timeout, $server_err, $server_close, $client_close);
64
64
Mojo::IOLoop-> remove(Mojo::IOLoop-> recurring(0 => sub { $remove ++ }));
65
65
$promise = Mojo::Promise-> new;
66
66
$id = Mojo::IOLoop-> server(
67
- address => ' 127.0.0.1 ' ,
67
+ address => ' localhost ' ,
68
68
tls => 1,
69
69
tls_ca => ' t/mojo/certs/ca.crt' ,
70
70
tls_cert => ' t/mojo/certs/server.crt' ,
@@ -88,6 +88,7 @@ $id = Mojo::IOLoop->server(
88
88
$port = Mojo::IOLoop-> acceptor($id )-> port;
89
89
$promise2 = Mojo::Promise-> new;
90
90
Mojo::IOLoop-> client(
91
+ address => ' localhost' ,
91
92
port => $port ,
92
93
tls => 1,
93
94
tls_cert => ' t/mojo/certs/client.crt' ,
@@ -118,6 +119,7 @@ ok !$server_err, 'no error';
118
119
# Invalid client certificate
119
120
my $client_err ;
120
121
Mojo::IOLoop-> client(
122
+ address => ' localhost' ,
121
123
port => $port ,
122
124
tls => 1,
123
125
tls_cert => ' t/mojo/certs/bad.crt' ,
@@ -133,7 +135,7 @@ ok $client_err, 'has error';
133
135
# Missing client certificate
134
136
($server_err , $client_err ) = ();
135
137
Mojo::IOLoop-> client(
136
- {port => $port , tls => 1} => sub {
138
+ {address => ' localhost ' , port => $port , tls => 1} => sub {
137
139
shift -> stop;
138
140
$client_err = shift ;
139
141
}
@@ -146,7 +148,7 @@ ok $client_err, 'has error';
146
148
$loop = Mojo::IOLoop-> new;
147
149
($server_err , $client_err ) = ();
148
150
$id = $loop -> server(
149
- address => ' 127.0.0.1 ' ,
151
+ address => ' localhost ' ,
150
152
tls => 1,
151
153
tls_ca => ' no cert' ,
152
154
tls_cert => ' t/mojo/certs/server.crt' ,
@@ -155,6 +157,7 @@ $id = $loop->server(
155
157
);
156
158
$port = $loop -> acceptor($id )-> port;
157
159
$loop -> client(
160
+ address => ' localhost' ,
158
161
port => $port ,
159
162
tls => 1,
160
163
tls_cert => ' t/mojo/certs/client.crt' ,
@@ -173,7 +176,7 @@ ok $client_err, 'has error';
173
176
($client , $client_close ) = ();
174
177
$promise = Mojo::Promise-> new;
175
178
$id = Mojo::IOLoop-> server(
176
- address => ' 127.0.0.1 ' ,
179
+ address => ' localhost ' ,
177
180
tls => 1,
178
181
tls_ca => ' t/mojo/certs/ca.crt' ,
179
182
tls_cert => ' t/mojo/certs/server.crt' ,
@@ -195,6 +198,7 @@ $id = Mojo::IOLoop->server(
195
198
$port = Mojo::IOLoop-> acceptor($id )-> port;
196
199
$promise2 = Mojo::Promise-> new;
197
200
Mojo::IOLoop-> client(
201
+ address => ' localhost' ,
198
202
port => $port ,
199
203
tls => 1,
200
204
tls_ca => ' t/mojo/certs/ca.crt' ,
@@ -227,17 +231,18 @@ ok !$server_err, 'no error';
227
231
$loop = Mojo::IOLoop-> new;
228
232
($server_err , $client_err ) = ();
229
233
$id = $loop -> server(
230
- address => ' 127.0.0.1 ' ,
234
+ address => ' localhost ' ,
231
235
tls => 1,
232
236
tls_cert => ' t/mojo/certs/bad.crt' ,
233
237
tls_key => ' t/mojo/certs/bad.key' ,
234
238
sub { $server_err = ' accepted' }
235
239
);
236
240
$port = $loop -> acceptor($id )-> port;
237
241
$loop -> client(
238
- port => $port ,
239
- tls => 1,
240
- tls_ca => ' t/mojo/certs/ca.crt' ,
242
+ address => ' localhost' ,
243
+ port => $port ,
244
+ tls => 1,
245
+ tls_ca => ' t/mojo/certs/ca.crt' ,
241
246
sub {
242
247
shift -> stop;
243
248
$client_err = shift ;
@@ -251,15 +256,15 @@ ok $client_err, 'has error';
251
256
$loop = Mojo::IOLoop-> new;
252
257
($server_err , $client_err ) = ();
253
258
$id = $loop -> server(
254
- address => ' 127.0.0.1 ' ,
259
+ address => ' localhost ' ,
255
260
tls => 1,
256
261
tls_cert => ' t/mojo/certs/bad.crt' ,
257
262
tls_key => ' t/mojo/certs/bad.key' ,
258
263
sub { $server_err = ' accepted' }
259
264
);
260
265
$port = $loop -> acceptor($id )-> port;
261
266
$loop -> client(
262
- address => ' 127.0.0.1 ' ,
267
+ address => ' localhost ' ,
263
268
port => $port ,
264
269
tls => 1,
265
270
tls_ca => ' t/mojo/certs/ca.crt' ,
@@ -276,17 +281,18 @@ ok $client_err, 'has error';
276
281
$loop = Mojo::IOLoop-> new;
277
282
($server_err , $client_err ) = ();
278
283
$id = $loop -> server(
279
- address => ' 127.0.0.1 ' ,
284
+ address => ' localhost ' ,
280
285
tls => 1,
281
286
tls_cert => ' t/mojo/certs/bad.crt' ,
282
287
tls_key => ' t/mojo/certs/bad.key' ,
283
288
sub { $server_err = ' accepted' }
284
289
);
285
290
$port = $loop -> acceptor($id )-> port;
286
291
$loop -> client(
287
- port => $port ,
288
- tls => 1,
289
- tls_ca => ' no cert' ,
292
+ address => ' localhost' ,
293
+ port => $port ,
294
+ tls => 1,
295
+ tls_ca => ' no cert' ,
290
296
sub {
291
297
shift -> stop;
292
298
$client_err = shift ;
@@ -301,7 +307,7 @@ $loop = Mojo::IOLoop->new;
301
307
my ($cipher , $version );
302
308
($server , $client , $client_err ) = ();
303
309
$id = $loop -> server(
304
- address => ' 127.0.0.1 ' ,
310
+ address => ' localhost ' ,
305
311
tls => 1,
306
312
tls_ca => ' t/mojo/certs/ca.crt' ,
307
313
tls_cert => ' t/mojo/certs/server.crt' ,
@@ -315,6 +321,7 @@ $id = $loop->server(
315
321
);
316
322
$port = $loop -> acceptor($id )-> port;
317
323
$loop -> client(
324
+ address => ' localhost' ,
318
325
port => $port ,
319
326
tls => 1,
320
327
tls_cert => ' t/mojo/certs/bad.crt' ,
@@ -340,7 +347,7 @@ is $cipher, $expect, "$expect has been negotiatied";
340
347
# Ignore missing client certificate
341
348
($server , $client , $client_err ) = ();
342
349
$id = Mojo::IOLoop-> server(
343
- address => ' 127.0.0.1 ' ,
350
+ address => ' localhost ' ,
344
351
tls => 1,
345
352
tls_ca => ' t/mojo/certs/ca.crt' ,
346
353
tls_cert => ' t/mojo/certs/server.crt' ,
@@ -350,7 +357,7 @@ $id = Mojo::IOLoop->server(
350
357
);
351
358
$port = Mojo::IOLoop-> acceptor($id )-> port;
352
359
Mojo::IOLoop-> client(
353
- {port => $port , tls => 1, tls_options => {SSL_verify_mode => 0x00}} => sub {
360
+ {address => ' localhost ' , port => $port , tls => 1, tls_options => {SSL_verify_mode => 0x00}} => sub {
354
361
shift -> stop;
355
362
$client = ' connected' ;
356
363
$client_err = shift ;
@@ -365,7 +372,7 @@ subtest 'ALPN' => sub {
365
372
plan skip_all => ' ALPN support required!' unless IO::Socket::SSL-> can_alpn;
366
373
my ($server_proto , $client_proto );
367
374
$id = Mojo::IOLoop-> server(
368
- address => ' 127.0.0.1 ' ,
375
+ address => ' localhost ' ,
369
376
tls => 1,
370
377
tls_options => {SSL_alpn_protocols => [' foo' , ' bar' , ' baz' ]},
371
378
sub {
@@ -376,6 +383,7 @@ subtest 'ALPN' => sub {
376
383
);
377
384
$port = Mojo::IOLoop-> acceptor($id )-> port;
378
385
Mojo::IOLoop-> client(
386
+ address => ' localhost' ,
379
387
port => $port ,
380
388
tls => 1,
381
389
tls_options => {SSL_alpn_protocols => [' baz' , ' bar' ], SSL_verify_mode => 0x00},
0 commit comments