/** * Calls the {@code #setHostname(String)} method of the underlying implementation * of {@link SSLSocket} if exists. * * Creates and initializes the single instance of the class when needed * * @param hostname The name of the server host of interest. * @param sslSocket Client socket to connect with the server. */ public static void setServerNameIndication(String hostname, SSLSocket sslSocket) { final Method setHostnameMethod = getMethod(sslSocket); if (setHostnameMethod != null) { try { setHostnameMethod.invoke(sslSocket, hostname); Log_OC.i(TAG, "SNI done, hostname: " + hostname); } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Call to SSLSocket#setHost(String) failed ", e); } catch (IllegalAccessException e) { Log_OC.e(TAG, "Call to SSLSocket#setHost(String) failed ", e); } catch (InvocationTargetException e) { Log_OC.e(TAG, "Call to SSLSocket#setHost(String) failed ", e); } } else { Log_OC.i(TAG, "SNI not supported"); } }
/** * Calls the {@code #setHostname(String)} method of the underlying implementation * of {@link SSLSocket} if exists. * * Creates and initializes the single instance of the class when needed * * @param hostname The name of the server host of interest. * @param sslSocket Client socket to connect with the server. */ public static void setServerNameIndication(String hostname, SSLSocket sslSocket) { final Method setHostnameMethod = getMethod(sslSocket); if (setHostnameMethod != null) { try { setHostnameMethod.invoke(sslSocket, hostname); Log_OC.i(TAG, "SNI done, hostname: " + hostname); } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Call to SSLSocket#setHost(String) failed ", e); } catch (IllegalAccessException e) { Log_OC.e(TAG, "Call to SSLSocket#setHost(String) failed ", e); } catch (InvocationTargetException e) { Log_OC.e(TAG, "Call to SSLSocket#setHost(String) failed ", e); } } else { Log_OC.i(TAG, "SNI not supported"); } }