From 8270adf703aca7b675986a41cc16fd6b83c7b76d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 1 Oct 2018 11:34:27 +0200 Subject: [PATCH] use sni and alpn for start tls as well. apperently google requires it --- .../java/eu/siacs/conversations/utils/TLSSocketFactory.java | 2 +- src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/utils/TLSSocketFactory.java b/src/main/java/eu/siacs/conversations/utils/TLSSocketFactory.java index 5ea3fb085..00bae7b75 100644 --- a/src/main/java/eu/siacs/conversations/utils/TLSSocketFactory.java +++ b/src/main/java/eu/siacs/conversations/utils/TLSSocketFactory.java @@ -57,7 +57,7 @@ public class TLSSocketFactory extends SSLSocketFactory { } private static Socket enableTLSOnSocket(Socket socket) { - if(socket != null && (socket instanceof SSLSocket)) { + if(socket instanceof SSLSocket) { SSLSocketHelper.setSecurity((SSLSocket) socket); } return socket; diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index f7815712d..299a37aa4 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -843,11 +843,14 @@ public class XmppConnection implements Runnable { final SSLSocket sslSocket = (SSLSocket) tlsFactoryVerifier.factory.createSocket(socket, address.getHostAddress(), socket.getPort(), true); + if (sslSocket == null) { throw new IOException("could not initialize ssl socket"); } SSLSocketHelper.setSecurity(sslSocket); + SSLSocketHelper.setHostname(sslSocket, account.getServer()); + SSLSocketHelper.setApplicationProtocol(sslSocket, "xmpp-client"); if (!tlsFactoryVerifier.verifier.verify(account.getServer(), this.verifiedHostname, sslSocket.getSession())) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": TLS certificate verification failed");