Skip to content

Swap to Netty's NPN/ALPN handling #180

Closed

Description

@ejona86

This should simplify our code and would allow us to support tcnative for OpenSSL support. Other than being faster, tcnative does not depend on the JRE version and does not need bootclasspath specified, which would help new users trying to use gRPC for the first time.

This is API breaking as it will change how we use SslContexts provided by the user. We will require them to be properly configured with ALPN protocols. Since SslContext does not allow any form of partial configuration or reconfiguration (no way that two parties can work together to configure one), we will probably need a helper class that duplicates almost all the factory methods but without the parameters we want to specify (like ALPN protocols).

Activity

  1. added this to the milestone on Mar 11, 2015
  2. ejona86 commented on Mar 11, 2015

    @ejona86
    MemberAuthor

    This would be really nice for 0.5.0, but not required.

  3. self-assigned this
    on Mar 11, 2015
  4. ejona86 commented on May 1, 2015

    @ejona86
    MemberAuthor

    The api-breaking portion has been completed. Actually swapping to use Netty's ALPN handling has not.

  5. removed this from the milestone on May 7, 2015
  6. added this to the 0.8.0 milestone on May 19, 2015
  7. nmittler commented on May 21, 2015

    @nmittler

    I suspect we should also add documentation for linux to use: -Djava.security.egd=file:/dev/./urandom

    As described in http://docs.oracle.com/cd/E13209_01/wlcp/wlss30/configwlss/jvmrand.html. The extra /./ is required in Java 5+ (http://stackoverflow.com/a/2325109)

    WDYT?

  8. nmittler commented on May 21, 2015

    @nmittler

    Actually I just ran our tests and this doesn't seem to affect the results. Perhaps it might make more of a difference on VMs (due to a lack of good entropy sources)?

  9. ejona86 commented on May 21, 2015

    @ejona86
    MemberAuthor

    The random stuff will be fast, until it isn't. You can look at /proc/sys/kernel/random/poolsize to see how closely /dev/random is to blocking. It will start low when just booting up, increase as you do I/O, and drain as you create TLS connections. If it reaches zero then new connections will block. If it doesn't reach zero, then /dev/./urandom won't cause any behavior difference.

  10. nmittler commented on May 21, 2015

    @nmittler

    @ejona86 what exactly is the purpose of this bug? To switch to using Netty's OpenSSL? If so, can we rename the bug accordingly?

  11. ejona86 commented on May 21, 2015

    @ejona86
    MemberAuthor

    No, this bug is to swap to Netty's ALPN, which is configured via SslContextBuilder with a ApplicationProtocolConfig. The only thing holding this up is running in Jetty (because of classpath issues), which our code is able to handle but we need to tweak things so that Netty's code works.

  12. ejona86 commented on May 21, 2015

    @ejona86
    MemberAuthor

    @nmittler, you can take a look at the current changes I have: ejona86@9dc615a . Pretty straight-forward, except that it doesn't work with Jetty because of ClassLoader issues.

  13. nmittler commented on May 22, 2015

    @nmittler

    FYI, jetty-project/jetty-alpn#8 and netty/netty#3819 have been fixed so Netty should now fail the handshake properly in all cases. The changes will be in 4.1.Beta6.

  14. ejona86 commented on May 22, 2015

    @ejona86
    MemberAuthor

    Those changes don't have any behavior change (that we care about), so it shouldn't matter yet which Netty version you are running.

  15. nmittler commented on May 22, 2015

    @nmittler

    I was under the impression that this was causing a RuntimeException to be propagated, which was not being handled by SslHandler in order to fail the handshake. This meant that our Server would silently fail the TLS negotiation and allow the RPCs to succeed. I'm coming in rather late to all of this, so I'm guessing my understanding is incorrect/incomplete. Is that not the case?

  16. ejona86 commented on May 22, 2015

    @ejona86
    MemberAuthor

    gRPC is currently not throwing an exception, but communicating the error through a side-channel. Netty was throwing an SSLHandshakeException (via a hack). We are using a Proxy in order to workaround Jetty. Proxy+SSLHandshakeException doesn't work because the Proxy notices the hack.

    As I understand the plan, we are going to tell Jetty users to configure Jetty for ALPN to work. The change to Netty removed the hack, which is nice. But since only Jetty and WildFire users are likely impacted, it seems using Proxy may be too ugly of a solution.

  17. nmittler commented on May 22, 2015

    @nmittler

    @ejona86 so the problem with Proxy should be resolved by this then, correct? Here's the relevant excerpt from your comments in jetty-project/jetty-alpn#8:

    Netty's current hack works today, but it is unable to be used with Proxy, and thus is harder to run within Jetty and other containers. Proxy notices that a checked exception was thrown from a method not throwing checked exceptions and wraps the SSLHandshakeException in UndeclaredThrowableException. The UndeclaredThrowableException is then subsequently wrapped in a RuntimeException by the SSL code.

    So this fixes our current solution of using Proxy, but we want to get rid of Proxy and use Netty's TLS support (hence this issue :)). So if we make the switch now, what will this mean for Jetty users? Will they be able to configure Jetty appropriately to get ALPN working?

  18. ejona86 commented on May 22, 2015

    @ejona86
    MemberAuthor

    I was originally planning on changing Netty to use Proxy, which is why I filed the issue with alpn-boot. I planned on Proxy since it seemed the "filter bootstrap classes" problem would be rampant in many different containers and so I would need a generic solution.

    However, after further investigation it appeared that only Jetty and WildFly may be impacted. That's when it became more reasonable to require configuration instead of working around the problem in our code. Using Netty's code today, Jetty users would need to add a WEB-INF/jetty-env.xml file to their WAR which whitelists the ALPN classes.

  19. nmittler commented on May 22, 2015

    @nmittler

    So it sounds like we have a reasonable solution ... should we proceed with your ejona86@9dc615a ?

  20. ejona86 commented on May 22, 2015

    @ejona86
    MemberAuthor

    I wanted to test with Jetty and guarantee we know the necessary configuration.

  21. nmittler commented on May 23, 2015

    @nmittler

    Right, we can use #483 as the starting point

  22. nmittler commented on May 28, 2015

    @nmittler

    I've tested locally and was able successfully use Netty's ALPN handling by deploying a war containing a jetty-env.xml with the following:

    <?xml version="1.0"  encoding="ISO-8859-1"?>
    <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
    <Configure class="org.eclipse.jetty.webapp.WebAppContext">
        <!-- Must be done in jetty-env.xml, since jetty-web.xml is loaded too late.   -->
        <!-- Removing ALPN from the blacklisted server classes (using "-" to remove). -->
        <!-- Must prepend to the blacklist since order matters.                       -->
        <Call name="prependServerClass">
            <Arg>-org.eclipse.jetty.alpn.</Arg>
        </Call>
    </Configure>
  23. added 3 commits that reference this issue on May 28, 2015
    9dd2514
    6f60b36
    89cce1d
  24. locked as resolved and limited conversation to collaborators on Sep 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions