code: private void disableCertificateVerification()
              throws KeyManagementException, NoSuchAlgorithmException {
          // Create a trust manager that does not validate certificate chains
          final TrustManager[] trustAllCerts = new TrustManager[] { new CustomTrustManager() };
  
          // Install the all-trusting trust manager
          final SSLContext sslContext = SSLContext.getInstance("SSL");
          sslContext.init(null, trustAllCerts, new SecureRandom());
          final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
          HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory);
          final HostnameVerifier verifier = new HostnameVerifier() {
              @Override
              public boolean verify(final String hostname,
                      final SSLSession session) {
                  return true;
              }
          };
  
          HttpsURLConnection.setDefaultHostnameVerifier(verifier);
      }
docs: Disable certificate verification.
  
  @throws KeyManagementException
  the key management exception
  @throws NoSuchAlgorithmException
  the no such algorithm exception