mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Throw exceptions of SSLSocket.startHandshake() in connect()
instead of throwing a NoResponseException in case startHandshake() throws an Exception. The NoResponseException was then thrown when performing SASL auth, which usually directly followes securing the connection via TLS (if enabled and provided by the server).
This commit is contained in:
parent
ddb47c2d60
commit
bc176d72a3
3 changed files with 32 additions and 5 deletions
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.jivesoftware.smack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
|
@ -26,7 +28,6 @@ import org.jivesoftware.smack.sasl.SASLMechanism.Challenge;
|
|||
import org.jivesoftware.smack.sasl.SASLMechanism.SASLFailure;
|
||||
import org.jivesoftware.smack.sasl.SASLMechanism.Success;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.SecurityRequiredException;
|
||||
import org.jivesoftware.smack.XMPPException.StreamErrorException;
|
||||
|
@ -92,8 +93,9 @@ class PacketReader {
|
|||
*
|
||||
* @throws NoResponseException if the server fails to send an opening stream back
|
||||
* within packetReplyTimeout.
|
||||
* @throws IOException
|
||||
*/
|
||||
synchronized public void startup() throws NoResponseException {
|
||||
synchronized public void startup() throws NoResponseException, IOException {
|
||||
readerThread.start();
|
||||
// Wait for stream tag before returning. We'll wait a couple of seconds before
|
||||
// giving up and throwing an error.
|
||||
|
@ -108,7 +110,7 @@ class PacketReader {
|
|||
// Ignore.
|
||||
}
|
||||
if (!lastFeaturesParsed) {
|
||||
throw new NoResponseException();
|
||||
connection.throwConnectionExceptionOrNoResponse();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -716,8 +716,15 @@ public class XMPPTCPConnection extends XMPPConnection {
|
|||
plain.getInetAddress().getHostAddress(), plain.getPort(), true);
|
||||
// Initialize the reader and writer with the new secured version
|
||||
initReaderAndWriter();
|
||||
// Proceed to do the handshake
|
||||
((SSLSocket) socket).startHandshake();
|
||||
|
||||
try {
|
||||
// Proceed to do the handshake
|
||||
((SSLSocket) socket).startHandshake();
|
||||
}
|
||||
catch (IOException e) {
|
||||
setConnectionException(e);
|
||||
throw e;
|
||||
}
|
||||
//if (((SSLSocket) socket).getWantClientAuth()) {
|
||||
// System.err.println("XMPPConnection wants client auth");
|
||||
//}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue