code: public static SSLSocketFactory getTrustAllCertSslSocketFactory() {
      try {
        TrustManager[] trustAllCerts = new TrustManager[]{
            new X509TrustManager() {
              @Override
              public void checkClientTrusted(X509Certificate[] chain, String authType)
                  throws CertificateException {
              }
  
              @Override
              public void checkServerTrusted(X509Certificate[] chain, String authType)
                  throws CertificateException {
              }
  
              @Override
              public X509Certificate[] getAcceptedIssuers() {
                return new X509Certificate[]{};
              }
            }
        };
  
        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
  
        return sslContext.getSocketFactory();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
docs: Helper method to create an empty {@link SSLSocketFactory} which trusts all certificates
  It is intended to be used only for testing purposes
  
  @return created empty factory