private static OkHttpClient getUnsafeOkHttpClient() {
  try {
    // Create a trust manager that does not validate certificate chains
    final TrustManager[] trustAllCerts = new TrustManager[] {
        new X509TrustManager() {
          public void checkClientTrusted([] chain, String authType) throws CertificateException {

          public void checkServerTrusted([] chain, String authType) throws CertificateException {

          public[] getAcceptedIssuers() {
            return new[]{};

    // Install the all-trusting trust manager
    final SSLContext sslContext = SSLContext.getInstance("SSL");
    sslContext.init(null, trustAllCerts, new;
    // 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(new HostnameVerifier() {
      public boolean verify(String hostname, SSLSession session) {
        return true;

    OkHttpClient okHttpClient =;
    return okHttpClient;
  } catch (Exception e) {
    throw new RuntimeException(e);

Fully customizable WordPress Multi-Purpose theme for any kind of business, blog, magazine, real estate agencies or portals and more.