Configure Netty SSL client sockets to send SNI header in Android
Asked Answered
G

1

6

I'd like to create an SSL/TLS connection using the Netty framework which will send a SNI header together during handshake. My current code looks like this:

SslContext creation:

    TrustManagerFactory trustManagerFactory = SimpleTrustManagerFactory.getInstance(
            SimpleTrustManagerFactory.getDefaultAlgorithm());
    trustManagerFactory.init((KeyStore)null);

    sslContext = SslContextBuilder
            .forClient()
            .sslProvider(SslProvider.JDK)
            // TODO p0: Ensure all the versions we support have this algorithm installed
            .trustManager(trustManagerFactory)
            .build();

Then during pipeline creation:

    pipeline.addLast(sslContext.newHandler(ch.alloc(), cloud.getHostName(), cloud.getPort()));

However the SNI header is NOT sent. What is missing to force Netty to provide SNI in the SSL Client Handshake?

Grouch answered 12/9, 2016 at 15:11 Comment(0)
V
0

I could set the SNI using sslContext.newHandler(allocator, SERVER_NAME, PORT), it works fine.

Villanueva answered 7/4, 2023 at 1:35 Comment(3)
For asking a clarification question (if you need it answered before you can provide a solution)k, the commenting privilege is needed. See meta.stackexchange.com/questions/214173/… BUt there is an option for users who do not have that privilege yet:Oppenheimer
Please phrase this as an explained conditional answer, in order to avoid the impression of asking a clarification question instead of answering (for which a comment should be used instead of an answer, compare meta.stackexchange.com/questions/214173/… ). For example like "If your problem is ... then the solution is to .... because .... ."Oppenheimer
I think the part I left is something of an answer, but that might be my lack of knowledge. So if it is not and you cannot edit as described above please delete the post.Oppenheimer

© 2022 - 2025 — McMap. All rights reserved.