package com.kofax.mobile.sdk.ak; import com.kofax.kmc.kut.utilities.CertificateValidatorListener; import io.grpc.internal.GrpcUtil; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSocketFactory; import o.C15329gne; import o.gmU; import o.gmY; /* loaded from: classes3.dex */ public class d { public static HttpURLConnection a(URL url, CertificateValidatorListener certificateValidatorListener) throws IOException { HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); if (url.getProtocol().equalsIgnoreCase("https") && (httpURLConnection instanceof HttpsURLConnection) && certificateValidatorListener != null) { HttpsURLConnection httpsURLConnection = (HttpsURLConnection) httpURLConnection; SSLSocketFactory sSLSocketFactory = certificateValidatorListener.getSSLSocketFactory(url.getHost()); if (sSLSocketFactory != null) { httpsURLConnection.setSSLSocketFactory(sSLSocketFactory); } } return httpURLConnection; } public static gmY a(String str, int i, CertificateValidatorListener certificateValidatorListener) throws IOException { gmY gmy; URL url = new URL(str); if (url.getProtocol().equalsIgnoreCase("https")) { String host = url.getHost(); int port = url.getPort(); String path = url.getPath(); if (port == -1) { port = GrpcUtil.DEFAULT_PORT_SSL; } gmy = new C15329gne(host, port, path, i); if (certificateValidatorListener != null) { gmU gmu = (gmU) gmy.b(); SSLSocketFactory sSLSocketFactory = certificateValidatorListener.getSSLSocketFactory(url.getHost()); if (sSLSocketFactory != null) { gmu.d.setSSLSocketFactory(sSLSocketFactory); } } } else { gmy = new gmY(str, i); } gmy.d = true; return gmy; } public static gmY a(String str, CertificateValidatorListener certificateValidatorListener) throws IOException { return a(str, 20000, certificateValidatorListener); } public static gmY aH(String str) throws IOException { return a(str, 20000, null); } }