MD5 校验值:d7f913ab91d7343430e85d5ce2e5aff0
CustomSSLSocketFactory.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.mopub.network; import android.net.SSLCertificateSocketFactory; import android.os.Build; import com.mopub.common.VisibleForTesting; import d9.ju; import ih.d; import java.net.InetAddress; import java.net.Socket; import java.net.SocketException; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; public final class CustomSSLSocketFactory extends SSLSocketFactory { public static final Companion Companion = new Companion(null); public SSLSocketFactory f19790a; public static final class Companion { private Companion() { } public Companion(d dVar) { this(); } public final CustomSSLSocketFactory getDefault(int i10) { CustomSSLSocketFactory customSSLSocketFactory = new CustomSSLSocketFactory(null); customSSLSocketFactory.f19790a = SSLCertificateSocketFactory.getDefault(i10, null); return customSSLSocketFactory; } @VisibleForTesting public final void verifyServerName(SSLSocket sSLSocket, String str) { ju.g(sSLSocket, "sslSocket"); sSLSocket.startHandshake(); if (!HttpsURLConnection.getDefaultHostnameVerifier().verify(str, sSLSocket.getSession())) { throw new SSLHandshakeException("Server Name Identification failed."); } } } private CustomSSLSocketFactory() { } public CustomSSLSocketFactory(d dVar) { this(); } public static final CustomSSLSocketFactory getDefault(int i10) { return Companion.getDefault(i10); } @VisibleForTesting public static final void verifyServerName(SSLSocket sSLSocket, String str) { Companion.verifyServerName(sSLSocket, str); } public final void a(Socket socket) { if (socket instanceof SSLSocket) { SSLSocket sSLSocket = (SSLSocket) socket; sSLSocket.setEnabledProtocols(sSLSocket.getSupportedProtocols()); } } @Override public Socket createSocket() { SSLSocketFactory sSLSocketFactory = this.f19790a; Socket createSocket = sSLSocketFactory != null ? sSLSocketFactory.createSocket() : null; a(createSocket); if (createSocket != null) { return createSocket; } throw new SocketException("SSLSocketFactory was null. Unable to create socket."); } @Override public Socket createSocket(String str, int i10) { ju.g(str, "host"); SSLSocketFactory sSLSocketFactory = this.f19790a; Socket createSocket = sSLSocketFactory != null ? sSLSocketFactory.createSocket(str, i10) : null; a(createSocket); if (createSocket != null) { return createSocket; } throw new SocketException("SSLSocketFactory was null. Unable to create socket."); } @Override public Socket createSocket(String str, int i10, InetAddress inetAddress, int i11) { ju.g(str, "host"); ju.g(inetAddress, "localhost"); SSLSocketFactory sSLSocketFactory = this.f19790a; Socket createSocket = sSLSocketFactory != null ? sSLSocketFactory.createSocket(str, i10, inetAddress, i11) : null; a(createSocket); if (createSocket != null) { return createSocket; } throw new SocketException("SSLSocketFactory was null. Unable to create socket."); } @Override public Socket createSocket(InetAddress inetAddress, int i10) { Socket createSocket; ju.g(inetAddress, "address"); SSLSocketFactory sSLSocketFactory = this.f19790a; if (sSLSocketFactory == null || (createSocket = sSLSocketFactory.createSocket(inetAddress, i10)) == null) { throw new SocketException("SSLSocketFactory was null. Unable to create socket."); } a(createSocket); return createSocket; } @Override public Socket createSocket(InetAddress inetAddress, int i10, InetAddress inetAddress2, int i11) { Socket createSocket; ju.g(inetAddress, "address"); ju.g(inetAddress2, "localhost"); SSLSocketFactory sSLSocketFactory = this.f19790a; if (sSLSocketFactory == null || (createSocket = sSLSocketFactory.createSocket(inetAddress, i10, inetAddress2, i11)) == null) { throw new SocketException("SSLSocketFactory was null. Unable to create socket."); } a(createSocket); return createSocket; } @Override public Socket createSocket(Socket socket, String str, int i10, boolean z10) { ju.g(str, "host"); SSLSocketFactory sSLSocketFactory = this.f19790a; if (sSLSocketFactory == null) { throw new SocketException("SSLSocketFactory was null. Unable to create socket."); } if (Build.VERSION.SDK_INT >= 23) { Socket createSocket = sSLSocketFactory.createSocket(socket, str, i10, z10); a(createSocket); ju.f(createSocket, "csf.createSocket(socketP…ble(it)\n }"); return createSocket; } if (z10 && socket != null) { socket.close(); } Socket createSocket2 = sSLSocketFactory.createSocket(InetAddressUtils.getInetAddressByName(str), i10); a(createSocket2); ju.f(createSocket2, "it"); SSLSocketFactory sSLSocketFactory2 = this.f19790a; if (sSLSocketFactory2 == null) { throw new SocketException("SSLSocketFactory was null. Unable to create socket."); } if (!(createSocket2 instanceof SSLSocket) || !(sSLSocketFactory2 instanceof SSLCertificateSocketFactory)) { return createSocket2; } ((SSLCertificateSocketFactory) sSLSocketFactory2).setHostname(createSocket2, str); Companion.verifyServerName((SSLSocket) createSocket2, str); return createSocket2; } @Override public String[] getDefaultCipherSuites() { String[] defaultCipherSuites; SSLSocketFactory sSLSocketFactory = this.f19790a; return (sSLSocketFactory == null || (defaultCipherSuites = sSLSocketFactory.getDefaultCipherSuites()) == null) ? new String[0] : defaultCipherSuites; } @Override public String[] getSupportedCipherSuites() { String[] supportedCipherSuites; SSLSocketFactory sSLSocketFactory = this.f19790a; return (sSLSocketFactory == null || (supportedCipherSuites = sSLSocketFactory.getSupportedCipherSuites()) == null) ? new String[0] : supportedCipherSuites; } @VisibleForTesting public final void setCertificateSocketFactory(SSLSocketFactory sSLSocketFactory) { ju.g(sSLSocketFactory, "sslSocketFactory"); this.f19790a = sSLSocketFactory; } }