diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-11-16 12:00:53 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-11-16 12:05:57 +0100 |
commit | f41f3b120cdf8ee07a6f10b17c38cbb6cb2692eb (patch) | |
tree | 561523d338d2665fdb0193b710dafc83e3742adf /src | |
parent | ac4eabbd2257217eebddfc33840a618e78a97cad (diff) |
better error checking in ssl switch over
Conflicts:
src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 15 |
1 files changed, 10 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 2b9d6632d..d59a302dc 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -18,6 +18,8 @@ import java.io.IOException; 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; @@ -553,12 +555,15 @@ public class XmppConnection implements Runnable { 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"); } - 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 |