content: package com.project.newsapp.utils.glidessl;
  
  
  import java.security.cert.CertificateException;
  
  import javax.net.ssl.SSLContext;
  import javax.net.ssl.SSLSocketFactory;
  import javax.net.ssl.TrustManager;
  import javax.net.ssl.X509TrustManager;
  
  import okhttp3.OkHttpClient;
  
  public class UnsafeOkHttpClient {
  
      public static OkHttpClient getUnsafeOkHttpClient() {
          try {
              // Create a trust manager that does not validate certificate chains
              final TrustManager[] trustAllCerts = new TrustManager[]{
                      new X509TrustManager() {
                          @Override
                          public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
                          }
  
                          @Override
                          public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
                          }
  
                          @Override
                          public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                              return new java.security.cert.X509Certificate[]{};
                          }
                      }
              };
  
              // Install the all-trusting trust manager
              final SSLContext sslContext = SSLContext.getInstance("SSL");
              sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
  
              // Create an ssl socket factory with our all-trusting manager
              final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
  
              OkHttpClient.Builder builder = new OkHttpClient.Builder();
              builder.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]);
              builder.hostnameVerifier((hostname, session) -> true);
  
              OkHttpClient okHttpClient = builder.build();
              return okHttpClient;
          } catch (Exception e) {
              throw new RuntimeException(e);
          }
      }
  
  }
  