Skip to content

Conscrypt support for SocketChannel instead of standard java.io.Socket #970

Open

Description

@yschimke

Repro'd a bug that seems to be JSSE or Conscrypt with SocketChannel sockets. It fails with both, so could be lower (JVM) or higher (OkHttp) in the stack.

lysine-dev/okhttp#6554

SocketChannelSocketFactory comes from Presto project https://github.com/prestodb/presto/blob/master/presto-client/src/main/java/com/facebook/presto/client/SocketChannelSocketFactory.java

But specifically, is SocketChannel socket a supported use case with Conscrypt?

Activity

  1. prbprbprb commented on Feb 9, 2021

    @prbprbprb
    Contributor

    It ought to work, and if it doesn't then we should fix it (so yes, supported).

    In theory you can layer a ConscryptEngineSocket[1] over any working Socket, including one which is itself layered over a SocketChannel. However it doesn't look like we have any test coverage for that case, but should be straightforward to add it to https://github.com/google/conscrypt/blob/master/openjdk/src/test/java/org/conscrypt/ConscryptSocketTest.java

    [1] ConscryptFileDescriptorSocket can't do TLS over TLS because reasons.

  2. prbprbprb commented on Feb 11, 2021

    @prbprbprb
    Contributor

    #971 mostly addresses this by ensuring we do all the tests in ConscryptSocketTest over SocketChannels to (both client and server side) and adds a test which sends actual data. The CI runs against various openjdk versions so let's see if it reproduces your issue.

    This test doesn't run on Android (because reasons), we'll need to add something for that case too.

  3. yschimke commented on Feb 11, 2021

    @yschimke
    ContributorAuthor

    FWIW I think ive found two issues.

    1 - the automatic SNIHostName in ssl params doesnt work. This was Java 8+ for regular sockets but seems broken for socketchannel

    2 - there is a deadlock i'm hitting with with h2. Likely because its a non typical IO workload

    Http 1.1 - write request. Then read response.
    General - two half duplex streams

    Http 2 - two streams with app level dependencies

  4. prbprbprb commented on Feb 12, 2021

    @prbprbprb
    Contributor

    Do you have a repro for either of those?

  5. yschimke commented on Feb 12, 2021

    @yschimke
    ContributorAuthor

    Let me restate my previous comment.

    "FWIW I think i've found two issues under JSSE.", My repro with JSSE currently using JUL logging which is very clear that SNI isn't being set.

    Unable to indicate server name
    Ignore, context unavailable extension: server_name
    

    But the repro for Conscrypt is just that it's blocking during the request then timing out.

  6. yschimke commented on Feb 12, 2021

    @yschimke
    ContributorAuthor

    The first problem with SNIHostName turns out to be that you can't use SNI with localhost! So I've switched to a fake "local.host"

    https://tools.ietf.org/html/rfc6066#page-6 specifies a FQDN is required.

  7. yschimke commented on Feb 13, 2021

    @yschimke
    ContributorAuthor

    Second looks to be a 3 thread deadlock between OkHttp and Channels.

    Thanks for adding the test.

  8. yschimke commented on Feb 13, 2021

    @yschimke
    ContributorAuthor

    Known limitation of channels lysine-dev/okhttp#6558

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions