Disable hostname verification in io.netty.handler.ssl.Sslcontext

前端 未结 2 965
面向向阳花
面向向阳花 2021-01-14 15:41

Is there a way to disable hostname verification for io.netty.handler.ssl.Sslcontext?

I have this code:

sslContext = SslContextBuilder
        .forCli         


        
2条回答
  •  被撕碎了的回忆
    2021-01-14 15:54

    I found that adding setAcceptAnyCertificate(true) to the clientConfig builder did the trick in this way:

    sslContext = SslContextBuilder
        .forClient()
        .sslProvider(SslProvider.JDK)
        .trustManager(InsecureTrustManagerFactory.INSTANCE)
        .build();
    
    DefaultAsyncHttpClientConfig.Builder builder = new DefaultAsyncHttpClientConfig.Builder();
    builder.setSslContext(sslContext)
        .setAcceptAnyCertificate(true);
    
    AsyncHttpClientConfig asyncHttpClientConfig = builder.build();
    

    Thanks everyone

提交回复
热议问题