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

etcdmain: tls listener MUST be at the outer layer of all listeners #4153

Merged
merged 1 commit into from
Jan 7, 2016

Conversation

xiang90
Copy link
Contributor

@xiang90 xiang90 commented Jan 7, 2016

go HTTP library uses type assertion to determine if a connection
is a TLS connection. If we wrapper TLS Listener with any customized
Listener that can create customized Conn, HTTPs will be broken.

This commit fixes the issue.

/cc @heyitsanthony I want to keep NewListener behaviors the same although we do not wrap it with any other listener now. While you were on it today, can you help to change it?

return nil, err
}

func NewKeepAliveListener(l net.Listener, scheme string, info TLSInfo) (net.Listener, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

So this patch is doing the same thing as the old code but it's passing a Listener into NewKeepAliveListener instead of expecting it to create one for you? There should be a comment here about why this is important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@heyitsanthony Right. The TLS one must be the most outside listener. So we need to prepare inner listener and then pass in that listener. I will document it.

@heyitsanthony
Copy link
Contributor

lgtm aside from documentation (and the typo in the commit message); it'd probably be good to type assert all custom wrappers to error out or panic if wrapping tls listeners but that might be overkill

@xiang90 xiang90 force-pushed the fix_listener branch 2 times, most recently from cc524f8 to 605a6b1 Compare January 7, 2016 18:08
@xiang90
Copy link
Contributor Author

xiang90 commented Jan 7, 2016

@heyitsanthony All fixed. Add a TODO for type assertion before passing the listener to HTTP server.

@heyitsanthony
Copy link
Contributor

ok LGTM, if CI is giving false positives. please fix the commit title though

go HTTP library uses type assertion to determine if a connection
is a TLS connection. If we wrapper TLS Listener with any customized
Listener that can create customized Conn, HTTPs will be broken.

This commit fixes the issue.
@xiang90 xiang90 changed the title etcdmian: tls listener MUST be at the outer layer of all listeners etcdmain: tls listener MUST be at the outer layer of all listeners Jan 7, 2016
xiang90 added a commit that referenced this pull request Jan 7, 2016
etcdmain: tls listener MUST be at the outer layer of all listeners
@xiang90 xiang90 merged commit 9e03789 into etcd-io:master Jan 7, 2016
@xiang90 xiang90 deleted the fix_listener branch January 7, 2016 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants