Sample code for 30+ languages & platforms
Tcl

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 Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set socket [new_CkSocket]

#  Connect to the server using TLS.
set bTls 1
set maxWaitMs 5000
set success [CkSocket_Connect $socket "example.com" 5000 $bTls $maxWaitMs]
if {$success == 0} then {
    puts [CkSocket_lastErrorText $socket]
    delete_CkSocket $socket
    exit
}

#  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.
set success [CkSocket_ConvertFromSsl $socket]
if {$success == 0} then {
    puts [CkSocket_lastErrorText $socket]
    delete_CkSocket $socket
    exit
}

puts "Reverted to a plain TCP connection."

delete_CkSocket $socket