Fix XMPPTCPConnection.setEnabledSSL(Protocols|Ciphers)

The problem caused by opening input/ output stream before setting ssl
parameters to SSLSession and fixed by changing order of this operations.

Fixes SMACK-712.

Minor-Modifications-By: Florian Schmaus <flo@geekplace.eu>
This commit is contained in:
Tomas Nosek 2016-02-08 10:07:14 +01:00 committed by Florian Schmaus
parent bcdfb5398a
commit cf3024668e
1 changed files with 6 additions and 2 deletions

View File

@ -751,12 +751,16 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
// Secure the plain connection
socket = context.getSocketFactory().createSocket(plain,
host, plain.getPort(), true);
// Initialize the reader and writer with the new secured version
initReaderAndWriter();
final SSLSocket sslSocket = (SSLSocket) socket;
// Immediately set the enabled SSL protocols and ciphers. See SMACK-712 why this is
// important (at least on certain platforms) and it seems to be a good idea anyways to
// prevent an accidental implicit handshake.
TLSUtils.setEnabledProtocolsAndCiphers(sslSocket, config.getEnabledSSLProtocols(), config.getEnabledSSLCiphers());
// Initialize the reader and writer with the new secured version
initReaderAndWriter();
// Proceed to do the handshake
sslSocket.startHandshake();