-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: added --- sni Support TLS http2 and SNI #68
Open
vislee
wants to merge
3
commits into
openresty:master
Choose a base branch
from
vislee:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2125,6 +2125,11 @@ sub gen_curl_cmd_from_req ($$) { | |
push @args, '--http2', '--http2-prior-knowledge'; | ||
} | ||
|
||
if (use_http2($block) && defined $block->tls) { | ||
my $resolve = "$ServerName:$ServerPortForClient:$ServerAddr"; | ||
push @args, '-k', '--resolve', $resolve; | ||
} | ||
|
||
if ($meth eq 'HEAD') { | ||
push @args, '-I'; | ||
|
||
|
@@ -2191,6 +2196,10 @@ sub gen_curl_cmd_from_req ($$) { | |
my $server = $ServerAddr; | ||
my $port = $ServerPortForClient; | ||
$link = "http://$server:$port$uri"; | ||
if (use_http2($block) && defined $block->tls) { | ||
my $server_name = $ServerName; | ||
$link = "https://$server_name:$port$uri"; | ||
} | ||
} | ||
|
||
push @args, $link; | ||
|
@@ -2864,6 +2873,7 @@ The following sections are supported: | |
=head2 http2 | ||
|
||
Enforces the test scaffold to use the HTTP/2 wire protocol to send the test request. | ||
Also, you can set tls section using the HTTP/2 over TLS protocol and SNI(Server Name Indication). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need to mention SNI here? It can be implicit I think. The user cannot specify their own SNI names now anyway. |
||
|
||
Under the hood, the test scaffold uses the `curl` command-line utility to do the wire communication | ||
with the NGINX server. The `curl` utility must be recent enough to support both the C<--http2> | ||
|
@@ -3991,6 +4001,10 @@ One can enable HTTP/2 mode for an individual test block by specifying the L<http | |
|
||
--- http2 | ||
|
||
Enable HTTP/2 over TLS mode for an individual test block by specifying the L<tls> section, as in | ||
|
||
--- tls | ||
|
||
=head2 TEST_NGINX_VERBOSE | ||
|
||
Controls whether to output verbose debugging messages in Test::Nginx. Default to empty. | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned in my previous round of review, the test scaffold should automatically generate self-signed server certificate and key files and automatically make use of them in the automatically generated
nginx.conf
. All such details should be transparent. Also, we can introduce aTEST_NGINX_USE_HTTP2_TLS=1
system environment to enable this for any existing tests without any edits in the tests themselves?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agentzh I think it can be split into two parts. Listening on HTTPS/2 and making HTTPS/2 requests from Test::Nginx.
I have tests that are using custom certificates and want to keep it that way, but would like to make HTTPS/2 request from Test::Nginx to verify them. IMO those are two different problems.
I see the workaround in ssl_certificate_by_lua tests (using cosockets), but having first class support in Test::Nginx would be nice.