diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index 64de91db5..afa817fc3 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -884,11 +884,9 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { return; } - if (config.getSecurityMode() == ConnectionConfiguration.SecurityMode.disabled) { - // Do not secure the connection using TLS since TLS was disabled - return; + if (config.getSecurityMode() != ConnectionConfiguration.SecurityMode.disabled) { + send(new StartTls()); } - send(new StartTls()); } // If TLS is required but the server doesn't offer it, disconnect // from the server and throw an error. First check if we've already negotiated TLS