Java
Chilkat2 Java
Revert a TLS Connection to Plain TCP
See more Socket/SSL/TLS Examples
Demonstrates Socket.ConvertFromSsl, which ends the TLS layer while leaving the underlying TCP connection open for subsequent unencrypted communication.
Background. This is the reverse of a STARTTLS-style upgrade and is valid only while TLS is currently active on the connection.
Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Socket;
public class ChilkatExample {
public static void main(String[] args) {
Socket socket = new Socket();
// Connect to the server using TLS.
boolean bTls = true;
int maxWaitMs = 5000;
try {
socket.connect("example.com", 5000, bTls, maxWaitMs);
// End the TLS layer while keeping the underlying TCP connection open for subsequent unencrypted
// communication. This is the reverse of a STARTTLS-style upgrade and is valid only while TLS is
// active.
socket.convertFromSsl();
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
System.out.println("Reverted to a plain TCP connection.");
}
}