Sample code for 30+ languages & platforms
Delphi DLL

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 Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
socket: HCkSocket;
bTls: Boolean;
maxWaitMs: Integer;

begin
success := False;

socket := CkSocket_Create();

//  Connect to the server using TLS.
bTls := True;
maxWaitMs := 5000;
success := CkSocket_Connect(socket,'example.com',5000,bTls,maxWaitMs);
if (success = False) then
  begin
    Memo1.Lines.Add(CkSocket__lastErrorText(socket));
    Exit;
  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 := CkSocket_ConvertFromSsl(socket);
if (success = False) then
  begin
    Memo1.Lines.Add(CkSocket__lastErrorText(socket));
    Exit;
  end;
Memo1.Lines.Add('Reverted to a plain TCP connection.');

CkSocket_Dispose(socket);