PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkSocket.pb"
Procedure ChilkatExample()
success.i = 0
socket.i = CkSocket::ckCreate()
If socket.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Connect to the server using TLS.
bTls.i = 1
maxWaitMs.i = 5000
success = CkSocket::ckConnect(socket,"example.com",5000,bTls,maxWaitMs)
If success = 0
Debug CkSocket::ckLastErrorText(socket)
CkSocket::ckDispose(socket)
ProcedureReturn
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.
success = CkSocket::ckConvertFromSsl(socket)
If success = 0
Debug CkSocket::ckLastErrorText(socket)
CkSocket::ckDispose(socket)
ProcedureReturn
EndIf
Debug "Reverted to a plain TCP connection."
CkSocket::ckDispose(socket)
ProcedureReturn
EndProcedure