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

Added support for TLS Application Layer Protocol Negotiation (ALPN) #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nmav
Copy link

@nmav nmav commented Feb 17, 2014

This patch adds support for ALPN, based on draft-ietf-tls-applayerprotoneg-04.
It adds the new keywords 'ALPNtable' and 'prefer'. The latter accepts the
values 'sni' or 'alpn'.

Signed-off-by: Nikos Mavrogiannopoulos [email protected]

src/backend.c Outdated
@@ -107,15 +107,17 @@ struct Backend *
}

struct Backend *
lookup_backend(const struct Backend_head *head, const char *hostname) {
lookup_backend(const struct Backend_head *head, const char *name, unsigned name_size) {
Copy link
Owner

Choose a reason for hiding this comment

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

For consistency can we got with size_t name_len rather than unsigned name_size.

@dlundquist
Copy link
Owner

Overall looks great. I wanted to avoid creating a dependencies for the protocol parsers on other modules (besides logger module and protocol header), can we avoid passing a reference to the listener to parse_tls_header()?

Could you provide some sample ALPN client hello messages for tls_test.c? Could you make sure make check runs cleanly?

@fniephaus fniephaus mentioned this pull request Feb 17, 2014
@nmav
Copy link
Author

nmav commented Feb 18, 2014

On Mon, Feb 17, 2014 at 7:29 PM, Dustin Lundquist
[email protected]:

Overall looks great. I wanted to avoid creating a dependencies for the
protocol parsers on other modules (besides logger module and protocol
header), can we avoid passing a reference to the listener to
parse_tls_header()?

I needed it so that it can access the information on the alpn_Table. I
don't see how I can avoid it, except from passing the ALPN table directly,
which looks quite worse. If you have any suggestions on that, it's welcome.

Could you provide some sample ALPN client hello messages for tls_test.c?

I've updated the request with tls_test.c as well.

regards,
Nikos

@dlundquist
Copy link
Owner

I haven't forgotten about this one. Hopefully I'll have some time this weekend to dig in further.

@nmav
Copy link
Author

nmav commented Mar 17, 2014

Hello,
Is there anything I can do to help this process?

@dlundquist
Copy link
Owner

Sorry for the long delay getting back to you, I haven't had much time to work on sniproxy over the last month. I'm still not real happy with the level of coupling this introduces and have been hacking on a local branch trying to find a more orthogonal way to introduce it.

From my reading about ALPN, I did have a few high level observations:

  1. We need to find the first ALPN protocol match in common between sniproxy and the client.
    • parse_packet() must either know all the protocols configured or return a list of all the protocols the client advertises support for.
      • we could add a opaque protocol data pointer to parse_packet() arguments and pass in a list of the protocols configured in sniproxy, each listener would contain its own protocol_data with a duplicate list of supported ALPN protocols.
  2. The ALPN protocol is an opaque string, and as such it could contain a null character.
    • PCRE match isn't quite appropriate
      • we could add an alternative function to table_lookup_server_address() which does a binary comparison

I'm still not clear in which cases both ALPN and SNI extensions would be present, or how that should be handled.

@nmav
Copy link
Author

nmav commented Apr 1, 2014

Hello,
About (2), I am not sure that protocols shouldn't be handled as strings and avoid pcre match. All the defined protocols are strings (http/2.0, http/1.0) and being able to match them with a regex is actually something that will be needed (e.g., match http/.*) . I also find it very unlikely to define protocols in the future that look something like 0x00060421. Nevertheless, the code could fallback to a simpler comparison if strlen()!=length, instead of forbidding pcre match completely.

About (1), I agree and this is the reason the Listener information was passed there. I don't know if passing fewer data there will actually provide any advantage, but it will be a bit cleaner separation as you say. I don't have much time to work on that now though.

dlundquist added a commit that referenced this pull request Apr 13, 2014
Conflicts:
	src/backend.c
	src/config.c
	src/connection.c
	src/listener.c
	src/listener.h
	tests/Makefile.am
	tests/tls_test.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants