Search code examples
javanetty

io.netty.handler.ssl.SslContext.newClientContext() deprecated in favor of?


  • What I am trying to achieve:

I would like to create a dummy SslContext (the one from io.netty.handler.ssl.SslContext, not SSLContext) during my testing.

  • What did I try:

Since it is a dummy and it is for testing only, I used io.netty.handler.ssl.SslContext.newClientContext() , which creates a SslContext object, probably not secure, but good enough for my tests.

  • Issue:

Unfortunately, now using netty-handler-4.1.100.Final.jar, SslContext.newClientContext() seems to be deprecated.

However, the doc does not mention what is the replacement.

    /** @deprecated */
    @Deprecated
    public static SslContext newClientContext() throws SSLException {
        return newClientContext((SslProvider)null, (File)null, (TrustManagerFactory)null);
    }
  • Question:

I do not have certificates, keys, or any other security related material, and would like to avoid creating some just for the sake of the test if possible. What is the non deprecated alternative to SslContext.newClientContext()?


Solution

  • As Aaron said (credits to him), we can use SslContextBuilder.forClient().build()