Lua
Lua
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 Lua Downloads
local chilkat = require("chilkat")
local socket = chilkat.Socket.new()
-- Connect to the server using TLS.
local bTls = true
local maxWaitMs = 5000
local success = socket:connect("example.com", 5000, bTls, maxWaitMs)
if not success then
print(socket.last_error_text)
return
end
-- 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 = socket:convert_from_ssl()
if not success then
print(socket.last_error_text)
return
end
print("Reverted to a plain TCP connection.")