diff options
3 files changed, 20 insertions, 6 deletions
diff --git a/android/src/main/java/com/squareup/okhttp/internal/Platform.java b/android/src/main/java/com/squareup/okhttp/internal/Platform.java index 9edd58e..53a6eab 100644 --- a/android/src/main/java/com/squareup/okhttp/internal/Platform.java +++ b/android/src/main/java/com/squareup/okhttp/internal/Platform.java @@ -122,9 +122,14 @@ public class Platform { } else { SET_USE_SESSION_TICKETS.invokeOptionalWithoutCheckedException(sslSocket, true); } - // Enable SNI - sslParams.setServerNames( - Collections.<SNIServerName>singletonList(new SNIHostName(hostname))); + try { + // Enable SNI + sslParams.setServerNames( + Collections.<SNIServerName>singletonList(new SNIHostName(hostname))); + } catch (IllegalArgumentException ignored) { + // The hostname isn't a valid SNI value, so ignore the exception and don't set + // a server name, which results in no SNI extension being sent. + } if (!isPlatformSocket(sslSocket)) { SET_HOSTNAME.invokeOptionalWithoutCheckedException(sslSocket, hostname); } diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/DelegatingSSLSocket.java b/okhttp-tests/src/test/java/com/squareup/okhttp/DelegatingSSLSocket.java index e13a50f..461279f 100644 --- a/okhttp-tests/src/test/java/com/squareup/okhttp/DelegatingSSLSocket.java +++ b/okhttp-tests/src/test/java/com/squareup/okhttp/DelegatingSSLSocket.java @@ -280,4 +280,8 @@ public abstract class DelegatingSSLSocket extends SSLSocket { @Override public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) { delegate.setPerformancePreferences(connectionTime, latency, bandwidth); } + + @Override public String getApplicationProtocol() { + return delegate.getApplicationProtocol(); + } } diff --git a/repackaged/android/src/main/java/com/android/okhttp/internal/Platform.java b/repackaged/android/src/main/java/com/android/okhttp/internal/Platform.java index f4505af..e0283f5 100644 --- a/repackaged/android/src/main/java/com/android/okhttp/internal/Platform.java +++ b/repackaged/android/src/main/java/com/android/okhttp/internal/Platform.java @@ -126,9 +126,14 @@ public class Platform { } else { SET_USE_SESSION_TICKETS.invokeOptionalWithoutCheckedException(sslSocket, true); } - // Enable SNI - sslParams.setServerNames( - Collections.<SNIServerName>singletonList(new SNIHostName(hostname))); + try { + // Enable SNI + sslParams.setServerNames( + Collections.<SNIServerName>singletonList(new SNIHostName(hostname))); + } catch (IllegalArgumentException ignored) { + // The hostname isn't a valid SNI value, so ignore the exception and don't set + // a server name, which results in no SNI extension being sent. + } if (!isPlatformSocket(sslSocket)) { SET_HOSTNAME.invokeOptionalWithoutCheckedException(sslSocket, hostname); } |