Sample code for 30+ languages & platforms
AutoIt

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

AutoIt
Local $bSuccess = False

$oSocket = ObjCreate("Chilkat.Socket")

;  Connect to the server using TLS.
Local $bTls = True
Local $iMaxWaitMs = 5000
$bSuccess = $oSocket.Connect("example.com",5000,$bTls,$iMaxWaitMs)
If ($bSuccess = False) Then
    ConsoleWrite($oSocket.LastErrorText & @CRLF)
    Exit
EndIf

;  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.
$bSuccess = $oSocket.ConvertFromSsl()
If ($bSuccess = False) Then
    ConsoleWrite($oSocket.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Reverted to a plain TCP connection." & @CRLF)