Skip to content
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

Add SSL Support - completion of PR#5 #36

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

ElvinEfendi
Copy link

This PR is based on the work done at #5.

It adds SSL support and addresses all the comments(tests and session reuse) made in the original PR.

One significant modification to the original PR is that now, the health check will fail if ssl_verify = true and the certificate verification fails.

/r @agentzh

@ElvinEfendi
Copy link
Author

ping

@charlescng
Copy link

@agentzh Can you review?

end

if ctx.type == "https" then
session, err = sock:sslhandshake(ctx.session, name, ctx.ssl_verify)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is session a global Lua variable? We should declare it as a local.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use the lua-releng script of nginx-devel-utils to check your Lua code. I'm getting the following errors by running this tool against your branch:

$ lua-releng
lib/resty/upstream/healthcheck.lua: 0.03 (0.03)
Checking use of Lua global variables in file lib/resty/upstream/healthcheck.lua...
	op no.	line	instruction	args	; code
	53	[237]	SETGLOBAL	11 -14	; session
	54	[238]	GETGLOBAL	11 -14	; session
	73	[244]	GETGLOBAL	11 -14	; session
Checking line length exceeding 80...

So apparently the session is a misused Lua global variable.

t/sanity.t Outdated
}

lua_shared_dict healthcheck 1m;
init_worker_by_lua '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use init_worker_by_lua_block here for newly added tests.

t/sanity.t Outdated
--- config
location = /t {
access_log off;
content_by_lua '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use content_by_lua_block in newly added tests. Please fix other similar places.

@agentzh
Copy link
Member

agentzh commented Feb 11, 2017

Also, please rebase to the latest git master.

@agentzh
Copy link
Member

agentzh commented Feb 11, 2017

@ElvinEfendi Thank you for your patch! Please take care of my comments above. Thanks!

@ElvinEfendi
Copy link
Author

@agentzh thanks for reviewing, I addressed your comments.

Also, please rebase to the latest git master.

I don't see any conflict with the upstream master(there were some initially but those have been sycned to this branch already). And all the commits from it are already included in this branch. Why do you think this branch is not in sync with the upstream master?

@ElvinEfendi
Copy link
Author

@agentzh any more comment on this PR?

@ElvinEfendi
Copy link
Author

By default peer.name(an entry defined inside upstream block as <host>:<port>) is being passed to tcpsock:sslhandshake function as server_name which is used to validate the server name specified in the server certificate sent from the remote when ssl_verify is true. Refer to https://github.com/openresty/lua-nginx-module#tcpsocksslhandshake for more information. This is a constraint when we want to share a single server certificate to do SSL health check between multiple peers. Therefore I added TEST 20 and 21 to make ssl_verify option's behaviour more clear and added a new functionality that lets users to override peer.name with a custom name set during the initialization. TEST 21 covers the new functionality. These changes are added in commit: ce88ef0

let users to pass custom server_name to tcpsock:sslhandshake function
@solio
Copy link

solio commented Jun 30, 2017

why this pr has not bean merged?
这个ssl support什么时候能合到主干上?

@agentzh
Copy link
Member

agentzh commented Jul 10, 2017

@solio This is still in my review queue. Sorry for the delay on my side.

@agentzh
Copy link
Member

agentzh commented Jul 10, 2017

@ElvinEfendi Will you please rebase to the latest git master? I'm seeing merge conflicts while rebasing it myself:

$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: add ssl support
Using index info to reconstruct a base tree...
M	README.markdown
M	lib/resty/upstream/healthcheck.lua
Falling back to patching base and 3-way merge...
Auto-merging lib/resty/upstream/healthcheck.lua
CONFLICT (content): Merge conflict in lib/resty/upstream/healthcheck.lua
Auto-merging README.markdown
error: Failed to merge in the changes.
Patch failed at 0001 add ssl support
The copy of the patch that failed is found in: .git/rebase-apply/patch

Thanks! And sorry for the delay on my side.

@ElvinEfendi
Copy link
Author

ElvinEfendi commented Jul 11, 2017

Will you please rebase to the latest git master? I'm seeing merge conflicts while rebasing it myself:

Hmm I don't know why does it show conflict. There's no commit in the upstream after 69751de which is already in downstream as well Shopify@69751de.

master...Shopify:master also shows "Able to merge":
screen shot 2017-07-10 at 11 05 48 pm

@ElvinEfendi
Copy link
Author

ElvinEfendi commented Jul 11, 2017

I'd also like to highlight that 6731f95 is not related to this PR, it is just included here because the downstream is Shopify fork's master.

If you don't want to merge that last unrelated commit, here is the PR with only SSL support: #44

@agentzh
Copy link
Member

agentzh commented Jul 12, 2017

@ElvinEfendi Cool, thanks!

@berlincount
Copy link

hmmm, may I ping on this PR? :)

@pavelnemirovsky
Copy link

@agentzh when do u plan to merge it? Thx

@agentzh
Copy link
Member

agentzh commented Feb 26, 2018

Sorry, we haven't had the time to look at this. Been busy with other things with higher priority.

@agentzh
Copy link
Member

agentzh commented Feb 26, 2018

@dndx @spacewander Please help review this PR once you have a chance. Thanks!

@ricardosantosalves
Copy link

Hi,
Is there any update regarding this PR?

@gentle-king
Copy link

Dears, any update on this feature?

@TWHOI
Copy link

TWHOI commented May 25, 2020

+1 year :-/
Would be nice to have this merged.

@doujiang24
Copy link
Member

@rainingmaster do you have time to take a look at this PR?

@leandromoreira
Copy link

@agentzh is there any plan to merge this ?

@leandromoreira
Copy link

Hi @ElvinEfendi did you publish a rock with these changes? If you didn't, I'm thinking to keep a lua-resty-upstream-healthcheck-ssl repo patching your changes to the main branch of this repo, what do you think?

@leandromoreira
Copy link

I copied this PR and released it as a rock https://github.com/globocom/lua-resty-upstream-healthcheck

type = "http",

-- type = "https",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not add such a comment in the sample code, here just keep the options related to https, detailed explanation is placed below

if typ ~= "http" then
return nil, "only \"http\" type is supported right now"
if typ ~= "http" and typ ~= "https" then
return nil, "no support for this protocol type"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to point out in the error message what the unsupported type is


server {
listen 12355;
ssl on;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the "ssl" directive is deprecated, use the "listen ... ssl" directive instead


server {
listen 12355;
ssl on;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


server {
listen 12355;
ssl on;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


server {
listen 12355;
ssl on;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


server {
listen 12355;
ssl on;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


server {
listen 12355;
ssl on;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


server {
listen 12355;
ssl on;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


server {
listen 12355;
ssl on;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.