美文网首页
react-native https

react-native https

作者: OK2018 | 来源:发表于2018-06-28 13:10 被阅读0次
package com.facebook.react.modules.network;


import javax.annotation.Nullable;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

public class OkHttpClientProvider {


  public static OkHttpClient.Builder createClientBuilder() {
    // No timeouts by default
    OkHttpClient.Builder client = new OkHttpClient.Builder()
      .connectTimeout(0, TimeUnit.MILLISECONDS)
      .readTimeout(0, TimeUnit.MILLISECONDS)
      .writeTimeout(0, TimeUnit.MILLISECONDS)
      .hostnameVerifier(new HostnameVerifier() {
        @Override
        public boolean verify(String hostname, SSLSession session) {
          return true; //忽略所有的认证,直接返回了true
        }
      })
      .cookieJar(new ReactCookieJarContainer());

    return enableTls12OnPreLollipop(client);
  }
}

相关文章

网友评论

      本文标题:react-native https

      本文链接:https://www.haomeiwen.com/subject/assgyftx.html