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

前端 未结 2 962
面向向阳花
面向向阳花 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:49

    This explains how you can import the certificate of the host you want to connect to: https://stackoverflow.com/a/36483016/5296666

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题