-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from h2o/master
Obtain the 0RTT checks
- Loading branch information
Showing
9 changed files
with
155 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDOjCCAiKgAwIBAgIBATANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDEwtIMk8g | ||
VGVzdCBDQTAeFw0xNDEyMTAxOTMzMDVaFw0yNDEyMDcxOTMzMDVaMBsxGTAXBgNV | ||
BAMTEDEyNy4wLjAuMS54aXAuaW8wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK | ||
AoIBAQDvNmF5nimH3wlp50E2/2SqxUD0JKaF3r2QFz1kB9UUwDhVDCms6PdkavF/ | ||
bQcHcWS+oa97D1miBQXo2Ns+6Z6JQ5sak/bVjnBxiU8vhqiOWvAwH947E4Km5HJB | ||
NFJJ7WEM+90kAFB2ayEM/llIQEt1RKCs2fgpaEgOMWPUAdcgyp6pNd60W5GA3Md2 | ||
1tdDH5RYGKzYHqpkm6pICtvaaxU4LwPmA3Oc8+VDDsVt08Jos1dJvoacjQTS6PpC | ||
ZiUDD2zqeSA//PGN8WV2o81SmsZwSpPCYBvxVW13tdsA1ivO5tng2fr9ZesKtXFZ | ||
SaH/tKmB3Br8jg2vUke/0cfIvbP/AgMBAAGjgY0wgYowCQYDVR0TBAIwADAsBglg | ||
hkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0O | ||
BBYEFJXhddVQ68vtPvxoHWHsYkLnu3+4MDAGA1UdIwQpMCehGqQYMBYxFDASBgNV | ||
BAMTC0gyTyBUZXN0IENBggkAmqS1V7DvzbYwDQYJKoZIhvcNAQELBQADggEBAJQ2 | ||
uvzL/lZnrsF4cvHhl/mg+s/RjHwvqFRrxOWUeWu2BQOGdd1Izqr8ZbF35pevPkXe | ||
j3zQL4Nf8OxO/gx4w0165KL4dYxEW7EaxsDQUI2aXSW0JNSvK2UGugG4+E4aT+9y | ||
cuBCtfWbL4/N6IMt2QW17B3DcigkreMoZavnnqRecQWkOx4nu0SmYg1g2QV4kRqT | ||
nvLt29daSWjNhP3dkmLTxn19umx26/JH6rqcgokDfHHO8tlDbc9JfyxYH01ZP2Ps | ||
esIiGa/LBXfKiPXxyHuNVQI+2cMmIWYf+Eu/1uNV3K55fA8806/FeklcQe/vvSCU | ||
Vw6RN5S/14SQnMYWr7E= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEpAIBAAKCAQEA7zZheZ4ph98JaedBNv9kqsVA9CSmhd69kBc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lp+7l/qW8LDImeYi8nWoqd6f1ye4iJdD0CgYEAlIApJljk5EFYeWIrmk3y | ||
EKoKewsNRqfNAkICoh4KL2PQxaAW8emqPq9ol47T5nVZOMnf8UYINnZ8EL7l3psA | ||
NtNJ1Lc4G+cnsooKGJnaUo6BZjTDSzJocsPoopE0Fdgz/zS60yOe8Y5LTKcTaaQ4 | ||
B+yOe74KNHSs/STOS4YBUskCgYAIqaRBZPsOo8oUs5DbRostpl8t2QJblIf13opF | ||
v2ZprN0ASQngwUqjm8sav5e0BQ5Fc7mSb5POO36KMp0ckV2/vO+VFGxuyFqJmlNN | ||
3Fapn1GDu1tZ/RYvGxDmn/CJsA26WXVnaeKXfStoB7KSueCBpI5dXOGgJRbxjtE3 | ||
tKV13QKBgQCtmLtTJPJ0Z+9n85C8kBonk2MCnD9JTYWoDQzNMYGabthzSqJqcEek | ||
dvhr82XkcHM+r6+cirjdQr4Qj7/2bfZesHl5XLvoJDB1YJIXnNJOELwbktrJrXLc | ||
dJ+MMvPvBAMah/tqr2DqgTGfWLDt9PJiCJVsuN2kD9toWHV08pY0Og== | ||
-----END RSA PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#! /usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
use Digest::MD5 qw(md5_hex); | ||
use File::Temp qw(tempdir); | ||
use Net::EmptyPort qw(check_port empty_port); | ||
use POSIX ":sys_wait_h"; | ||
use Scope::Guard qw(scope_guard); | ||
use Test::More; | ||
use Time::HiRes qw(sleep); | ||
|
||
$ENV{BINARY_DIR} ||= "."; | ||
my $cli = "$ENV{BINARY_DIR}/cli"; | ||
my $port = empty_port(); | ||
my $tempdir = tempdir(CLEANUP => 1); | ||
|
||
subtest "hello" => sub { | ||
my $guard = spawn_server(qw(-i t/assets/hello.txt)); | ||
subtest "full-handshake" => sub { | ||
my $resp = `$cli 127.0.0.1 $port 2> /dev/null`; | ||
is $resp, "hello"; | ||
}; | ||
subtest "resumption" => sub { | ||
for (1..10) { | ||
my $resp = `$cli -s $tempdir/session 127.0.0.1 $port 2> /dev/null`; | ||
is $resp, "hello"; | ||
} | ||
}; | ||
}; | ||
|
||
unlink "$tempdir/session"; | ||
|
||
subtest "early-data" => sub { | ||
subtest "success" => sub { | ||
my $guard = spawn_server(qw(-i t/assets/hello.txt -l), "$tempdir/events"); | ||
my $resp = `$cli -s $tempdir/session 127.0.0.1 $port`; | ||
is $resp, "hello"; | ||
$resp = `$cli -e -s $tempdir/session 127.0.0.1 $port`; | ||
is $resp, "hello"; | ||
like slurp_file("$tempdir/events"), qr/^CLIENT_EARLY_TRAFFIC_SECRET /m; | ||
$resp = `$cli -e -s $tempdir/session 127.0.0.1 $port`; | ||
is $resp, "hello"; | ||
is 2, (() = slurp_file("$tempdir/events") =~ /^CLIENT_EARLY_TRAFFIC_SECRET /mg); | ||
# check +15 seconds jitter | ||
$resp = `faketime -f +15 $cli -e -s $tempdir/session 127.0.0.1 $port`; | ||
is $resp, "hello"; | ||
is 2, (() = slurp_file("$tempdir/events") =~ /^CLIENT_EARLY_TRAFFIC_SECRET /mg); | ||
# re-fetch the ticket | ||
unlink "$tempdir/session"; | ||
$resp = `$cli -e -s $tempdir/session 127.0.0.1 $port`; | ||
is $resp, "hello"; | ||
is 2, (() = slurp_file("$tempdir/events") =~ /^CLIENT_EARLY_TRAFFIC_SECRET /mg); | ||
# check -15 seconds jitter | ||
$resp = `faketime -f -15 $cli -e -s $tempdir/session 127.0.0.1 $port`; | ||
is $resp, "hello"; | ||
is 2, (() = slurp_file("$tempdir/events") =~ /^CLIENT_EARLY_TRAFFIC_SECRET /mg); | ||
}; | ||
}; | ||
|
||
done_testing; | ||
|
||
sub spawn_server { | ||
my @cmd = ($cli, "-k", "t/assets/server.key", "-c", "t/assets/server.crt", @_, "127.0.0.1", $port); | ||
my $pid = fork; | ||
die "fork failed:$!" | ||
unless defined $pid; | ||
if ($pid == 0) { | ||
exec @cmd; | ||
die "failed to exec $cmd[0]:$?"; | ||
} | ||
while (!check_port($port)) { | ||
sleep 0.1; | ||
} | ||
return scope_guard(sub { | ||
kill 9, $pid; | ||
while (waitpid($pid, 0) != $pid) {} | ||
}); | ||
} | ||
|
||
sub slurp_file { | ||
my $fn = shift; | ||
open my $fh, "<", $fn | ||
or die "failed to open file:$fn:$!"; | ||
do { | ||
local $/; | ||
<$fh>; | ||
}; | ||
} |