aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-16 12:00:53 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-16 12:00:53 +0100
commitf18f3086afeb576206ad93c3875758d5514a09aa (patch)
treee323aefb21f94a8f9d74b717b0e6a87886ed76fb /src
parent2067b9bd8dcbace4b5d029a8266e9d195a3d573d (diff)
better error checking in ssl switch over
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 9148aa72..9e6b8baf 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -21,6 +21,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.net.IDN;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
@@ -574,12 +575,15 @@ public class XmppConnection implements Runnable {
final HostnameVerifier verifier = this.mXmppConnectionService.getMemorizingTrustManager().wrapHostnameVerifier(new StrictHostnameVerifier());
- if (socket == null) {
- throw new IOException("socket was null");
+ if (socket == null || socket.isClosed()) {
+ throw new IOException("socket null or closed");
}
- final SSLSocket sslSocket = (SSLSocket) factory.createSocket(socket,
- socket.getInetAddress().getHostAddress(), socket.getPort(),
- true);
+ final InetAddress address = socket.getInetAddress();
+ if (address == null) {
+ throw new IOException("socket address was null");
+ }
+
+ final SSLSocket sslSocket = (SSLSocket) factory.createSocket(socket,address.getHostAddress(), socket.getPort(),true);
// Support all protocols except legacy SSL.
// The min SDK version prevents us having to worry about SSLv2. In